diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:51:28 +0000 |
commit | 940b4d1848e8c70ab7642901a68594e8016caffc (patch) | |
tree | eb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /include/vcl | |
parent | Initial commit. (diff) | |
download | libreoffice-upstream.tar.xz libreoffice-upstream.zip |
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
256 files changed, 45716 insertions, 0 deletions
diff --git a/include/vcl/AccessibleBrowseBoxObjType.hxx b/include/vcl/AccessibleBrowseBoxObjType.hxx new file mode 100644 index 000000000..28086d7b1 --- /dev/null +++ b/include/vcl/AccessibleBrowseBoxObjType.hxx @@ -0,0 +1,44 @@ +/* -*- 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_ACCESSIBLEBROWSEBOXOBJTYPE_HXX +#define INCLUDED_VCL_ACCESSIBLEBROWSEBOXOBJTYPE_HXX + +namespace vcl { + +/** This enumeration contains a constant for each kind of accessible object of + a BrowseBox. */ +enum AccessibleBrowseBoxObjType +{ + BBTYPE_BROWSEBOX, /// The BrowseBox itself. + BBTYPE_TABLE, /// The data table. + BBTYPE_ROWHEADERBAR, /// The row header bar ("handle column"). + BBTYPE_COLUMNHEADERBAR, /// The horizontal column header bar. + BBTYPE_TABLECELL, /// A cell of the data table. + BBTYPE_ROWHEADERCELL, /// A cell of the row header bar. + BBTYPE_COLUMNHEADERCELL, /// A cell of the column header bar. + BBTYPE_CHECKBOXCELL /// A cell with a checkbox. +}; + +} // namespace svt + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapAccessMode.hxx b/include/vcl/BitmapAccessMode.hxx new file mode 100644 index 000000000..66cc2b56b --- /dev/null +++ b/include/vcl/BitmapAccessMode.hxx @@ -0,0 +1,32 @@ +/* -*- 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_BITMAPACCESSMODE_HXX +#define INCLUDED_VCL_BITMAPACCESSMODE_HXX + +enum class BitmapAccessMode +{ + Info, + Read, + Write +}; + +#endif // INCLUDED_VCL_BITMAPACCESSMODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapAlphaClampFilter.hxx b/include/vcl/BitmapAlphaClampFilter.hxx new file mode 100644 index 000000000..c8b111d93 --- /dev/null +++ b/include/vcl/BitmapAlphaClampFilter.hxx @@ -0,0 +1,34 @@ +/* -*- 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_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX +#define INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +/** If the alpha is beyond a certain threshold, make it fully transparent + */ +class VCL_DLLPUBLIC BitmapAlphaClampFilter final : public BitmapFilter +{ +public: + BitmapAlphaClampFilter(sal_uInt8 cThreshold) + : mcThreshold(cThreshold) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt8 mcThreshold; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapBasicMorphologyFilter.hxx b/include/vcl/BitmapBasicMorphologyFilter.hxx new file mode 100644 index 000000000..c7999dc28 --- /dev/null +++ b/include/vcl/BitmapBasicMorphologyFilter.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/. + * + */ + +#ifndef INCLUDED_VCL_BITMAPBASICMORPHOLOGYFILTER_HXX +#define INCLUDED_VCL_BITMAPBASICMORPHOLOGYFILTER_HXX + +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/BitmapFilter.hxx> + +enum class BasicMorphologyOp +{ + erode, + dilate +}; + +/* Black is foreground, white is background */ +class VCL_DLLPUBLIC BitmapBasicMorphologyFilter : public BitmapFilter +{ +public: + BitmapBasicMorphologyFilter(BasicMorphologyOp op, sal_Int32 nRadius); + BitmapBasicMorphologyFilter(BasicMorphologyOp op, sal_Int32 nRadius, sal_uInt8 nValueOutside); + virtual ~BitmapBasicMorphologyFilter(); + + virtual BitmapEx execute(BitmapEx const& rBitmap) const override; + +private: + Bitmap filter(Bitmap const& rBitmap) const; + + BasicMorphologyOp m_eOp; + sal_Int32 m_nRadius; + sal_uInt8 m_nValueOutside = 0; + bool m_bUseValueOutside = false; +}; + +class BitmapErodeFilter : public BitmapBasicMorphologyFilter +{ +public: + BitmapErodeFilter(sal_Int32 nRadius) + : BitmapBasicMorphologyFilter(BasicMorphologyOp::erode, nRadius) + { + } + BitmapErodeFilter(sal_Int32 nRadius, sal_uInt8 nValueOutside) + : BitmapBasicMorphologyFilter(BasicMorphologyOp::erode, nRadius, nValueOutside) + { + } +}; + +class BitmapDilateFilter : public BitmapBasicMorphologyFilter +{ +public: + BitmapDilateFilter(sal_Int32 nRadius) + : BitmapBasicMorphologyFilter(BasicMorphologyOp::dilate, nRadius) + { + } + BitmapDilateFilter(sal_Int32 nRadius, sal_uInt8 nValueOutside) + : BitmapBasicMorphologyFilter(BasicMorphologyOp::dilate, nRadius, nValueOutside) + { + } +}; + +#endif // INCLUDED_VCL_BITMAPBASICMORPHOLOGYFILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapBuffer.hxx b/include/vcl/BitmapBuffer.hxx new file mode 100644 index 000000000..2a064951c --- /dev/null +++ b/include/vcl/BitmapBuffer.hxx @@ -0,0 +1,48 @@ +/* -*- 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_BITMAPBUFFER_HXX +#define INCLUDED_VCL_BITMAPBUFFER_HXX + +#include <vcl/dllapi.h> +#include <vcl/BitmapPalette.hxx> +#include <vcl/ColorMask.hxx> +#include <vcl/Scanline.hxx> + +struct SalTwoRect; + +struct VCL_DLLPUBLIC BitmapBuffer +{ + ScanlineFormat mnFormat; + long mnWidth; + long mnHeight; + long mnScanlineSize; + sal_uInt16 mnBitCount; + ColorMask maColorMask; + BitmapPalette maPalette; + sal_uInt8* mpBits; +}; + +VCL_DLLPUBLIC std::unique_ptr<BitmapBuffer> StretchAndConvert( + const BitmapBuffer& rSrcBuffer, const SalTwoRect& rTwoRect, + ScanlineFormat nDstBitmapFormat, const BitmapPalette* pDstPal = nullptr, const ColorMask* pDstMask = nullptr ); + +#endif // INCLUDED_VCL_BITMAPBUFFER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapColor.hxx b/include/vcl/BitmapColor.hxx new file mode 100644 index 000000000..0ae037045 --- /dev/null +++ b/include/vcl/BitmapColor.hxx @@ -0,0 +1,83 @@ +/* -*- 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_BITMAPCOLOR_HXX +#define INCLUDED_VCL_BITMAPCOLOR_HXX + +#include <vcl/dllapi.h> +#include <tools/color.hxx> + +class VCL_DLLPUBLIC BitmapColor final : public Color +{ +public: + inline BitmapColor(); + constexpr BitmapColor( sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue, sal_uInt8 cAlpha = 0 ); + + inline BitmapColor( const Color& rColor ); + explicit inline BitmapColor( sal_uInt8 cIndex ); + + inline sal_uInt8 GetIndex() const; + inline void SetIndex( sal_uInt8 cIndex ); + + inline sal_uInt8 GetAlpha() const; + inline void SetAlpha( sal_uInt8 cAlpha ); +}; + +inline BitmapColor::BitmapColor() +{ +} + +inline BitmapColor::BitmapColor( const Color& rColor ) + : Color(rColor) +{ +} + +constexpr BitmapColor::BitmapColor(sal_uInt8 cRed, sal_uInt8 cGreen, sal_uInt8 cBlue, sal_uInt8 cAlpha) + : Color(cAlpha, cRed, cGreen, cBlue) +{ +} + +inline BitmapColor::BitmapColor( sal_uInt8 cIndex ) +{ + SetIndex(cIndex); +} + +inline sal_uInt8 BitmapColor::GetIndex() const +{ + return GetBlue(); +} + +inline void BitmapColor::SetIndex( sal_uInt8 cIndex ) +{ + SetBlue(cIndex); +} + +inline sal_uInt8 BitmapColor::GetAlpha() const +{ + return GetTransparency(); +} + +inline void BitmapColor::SetAlpha( sal_uInt8 cAlpha ) +{ + SetTransparency(cAlpha); +} + +#endif // INCLUDED_VCL_BITMAPCOLOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapColorQuantizationFilter.hxx b/include/vcl/BitmapColorQuantizationFilter.hxx new file mode 100644 index 000000000..266a384a3 --- /dev/null +++ b/include/vcl/BitmapColorQuantizationFilter.hxx @@ -0,0 +1,43 @@ +/* -*- 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_INCLUDE_VCL_BITMAPCOLORQUANTIZATIONFILTER_HXX +#define INCLUDED_INCLUDE_VCL_BITMAPCOLORQUANTIZATIONFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapColorQuantizationFilter final : public BitmapFilter +{ +public: + /** Reduce number of colors for the bitmap using the POPULAR algorithm + + @param nNewColorCount + Maximal number of bitmap colors after the reduce operation + */ + BitmapColorQuantizationFilter(sal_uInt16 nNewColorCount) + : mnNewColorCount(nNewColorCount) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt16 mnNewColorCount; + + struct PopularColorCount + { + sal_uInt32 mnIndex; + sal_uInt32 mnCount; + }; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapConvolutionMatrixFilter.hxx b/include/vcl/BitmapConvolutionMatrixFilter.hxx new file mode 100644 index 000000000..185d14012 --- /dev/null +++ b/include/vcl/BitmapConvolutionMatrixFilter.hxx @@ -0,0 +1,36 @@ +/* -*- 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_BITMAPCONVOLUTIONMATRIXFILTER_HXX +#define INCLUDED_VCL_BITMAPCONVOLUTIONMATRIXFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +/** Filter image based on a 3x3 convolution matrix + */ +class VCL_DLLPUBLIC BitmapConvolutionMatrixFilter : public BitmapFilter +{ +public: + BitmapConvolutionMatrixFilter(const long (&rMatrix)[9]) + : mrMatrix(rMatrix) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + const long (&mrMatrix)[9]; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapDuoToneFilter.hxx b/include/vcl/BitmapDuoToneFilter.hxx new file mode 100644 index 000000000..bb83a121f --- /dev/null +++ b/include/vcl/BitmapDuoToneFilter.hxx @@ -0,0 +1,36 @@ +/* -*- 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_BITMAPDUOTONEFILTER_HXX +#define INCLUDED_VCL_BITMAPDUOTONEFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class BitmapDuoToneFilter final : public BitmapFilter +{ +public: + BitmapDuoToneFilter(sal_uLong nColorOne, sal_uLong nColorTwo) + : mnColorOne(nColorOne) + , mnColorTwo(nColorTwo) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uLong mnColorOne; + sal_uLong mnColorTwo; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapEmbossGreyFilter.hxx b/include/vcl/BitmapEmbossGreyFilter.hxx new file mode 100644 index 000000000..2f1d309e0 --- /dev/null +++ b/include/vcl/BitmapEmbossGreyFilter.hxx @@ -0,0 +1,36 @@ +/* -*- 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_BITMAPEMBOSSGREYFILTER_HXX +#define INCLUDED_VCL_BITMAPEMBOSSGREYFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapEmbossGreyFilter final : public BitmapFilter +{ +public: + BitmapEmbossGreyFilter(sal_uInt16 nAzimuthAngle100, sal_uInt16 nElevationAngle100) + : mnAzimuthAngle100(nAzimuthAngle100) + , mnElevationAngle100(nElevationAngle100) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt16 mnAzimuthAngle100; + sal_uInt16 mnElevationAngle100; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapFilter.hxx b/include/vcl/BitmapFilter.hxx new file mode 100644 index 000000000..19599d063 --- /dev/null +++ b/include/vcl/BitmapFilter.hxx @@ -0,0 +1,31 @@ +/* -*- 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_BITMAPFILTER_HXX +#define INCLUDED_VCL_BITMAPFILTER_HXX + +#include <vcl/bitmapex.hxx> +class Animation; + +class VCL_DLLPUBLIC BitmapFilter +{ +public: + BitmapFilter(); + virtual ~BitmapFilter(); + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const = 0; + + static bool Filter(BitmapEx& rBmpEx, BitmapFilter const& rFilter); + static bool Filter(Animation& rBmpEx, BitmapFilter const& rFilter); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapFilterStackBlur.hxx b/include/vcl/BitmapFilterStackBlur.hxx new file mode 100644 index 000000000..8ac6a47e9 --- /dev/null +++ b/include/vcl/BitmapFilterStackBlur.hxx @@ -0,0 +1,33 @@ +/* -*- 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_BITMAPFILTERSTACKBLUR_HXX +#define INCLUDED_VCL_BITMAPFILTERSTACKBLUR_HXX + +#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapFilterStackBlur : public BitmapFilter +{ + sal_Int32 mnRadius; + +public: + BitmapFilterStackBlur(sal_Int32 nRadius); + virtual ~BitmapFilterStackBlur(); + + virtual BitmapEx execute(BitmapEx const& rBitmap) const override; + + Bitmap filter(Bitmap const& rBitmap) const; +}; + +#endif // INCLUDED_VCL_BITMAPFILTERSTACKBLUR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapGaussianSeparableBlurFilter.hxx b/include/vcl/BitmapGaussianSeparableBlurFilter.hxx new file mode 100644 index 000000000..72b3fdb81 --- /dev/null +++ b/include/vcl/BitmapGaussianSeparableBlurFilter.hxx @@ -0,0 +1,52 @@ +/* -*- 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_BITMAPGAUSSIANSEPARABLEBLURFILTER_HXX +#define INCLUDED_VCL_BITMAPGAUSSIANSEPARABLEBLURFILTER_HXX + +#include <vcl/BitmapFilter.hxx> +#include <vector> + +class BitmapEx; + +class BitmapGaussianSeparableBlurFilter final : public BitmapFilter +{ +public: + BitmapGaussianSeparableBlurFilter(double fRadius) + : mfRadius(fRadius) + { + } + + /** Separable Gaussian Blur filter and accepts a blur radius + as a parameter so the user can change the strength of the blur. + Radius of 1.0 is 3 * standard deviation of gauss function. + + Separable Blur implementation uses 2x separable 1D convolution + to process the image. + */ + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + double mfRadius; + + static bool convolutionPass(const Bitmap& rBitmap, Bitmap& aNewBitmap, + BitmapReadAccess const* pReadAcc, int aNumberOfContributions, + const double* pWeights, int const* pPixels, const int* pCount); + + static std::vector<double> makeBlurKernel(const double radius, int& rows); + static void blurContributions(const int aSize, const int aNumberOfContributions, + const std::vector<double>& rBlurVector, + std::vector<double>& rWeights, std::vector<int>& rPixels, + std::vector<int>& rCounts); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapMedianFilter.hxx b/include/vcl/BitmapMedianFilter.hxx new file mode 100644 index 000000000..941ba0dae --- /dev/null +++ b/include/vcl/BitmapMedianFilter.hxx @@ -0,0 +1,28 @@ +/* -*- 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_BITMAPMEDIANFILTER_HXX +#define INCLUDED_VCL_BITMAPMEDIANFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapMedianFilter final : public BitmapFilter +{ +public: + BitmapMedianFilter() {} + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapMonochromeFilter.hxx b/include/vcl/BitmapMonochromeFilter.hxx new file mode 100644 index 000000000..81a505e1f --- /dev/null +++ b/include/vcl/BitmapMonochromeFilter.hxx @@ -0,0 +1,43 @@ +/* -*- 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_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX +#define INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapMonochromeFilter final : public BitmapFilter +{ +public: + /** Convert to 2 color bitmap. + + Converts to a 2 color indexed bitmap - note that we don't change to black + and white monochrome, but we pick the closest color to black and white in + the bitmap. + + @param cThreshold + Luminance value that determines whether the colour should be black (or + closest color to black) or white (or closest color to white). + + */ + BitmapMonochromeFilter(sal_uInt8 cThreshold) + : mcThreshold(cThreshold) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt8 mcThreshold; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapMosaicFilter.hxx b/include/vcl/BitmapMosaicFilter.hxx new file mode 100644 index 000000000..6f88b228f --- /dev/null +++ b/include/vcl/BitmapMosaicFilter.hxx @@ -0,0 +1,40 @@ +/* -*- 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_BITMAPMOSAICFILTER_HXX +#define INCLUDED_VCL_BITMAPMOSAICFILTER_HXX + +#include <sal/config.h> + +#include <algorithm> + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapMosaicFilter final : public BitmapFilter +{ +public: + BitmapMosaicFilter(sal_uLong nTileWidth, sal_uLong nTileHeight) + : mnTileWidth(std::max(nTileWidth, sal_uLong(1))) + , mnTileHeight(std::max(nTileHeight, sal_uLong(1))) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uLong mnTileWidth; + sal_uLong mnTileHeight; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapPalette.hxx b/include/vcl/BitmapPalette.hxx new file mode 100644 index 000000000..9a2d08d4d --- /dev/null +++ b/include/vcl/BitmapPalette.hxx @@ -0,0 +1,139 @@ +/* -*- 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_BITMAPPALETTE_HXX +#define INCLUDED_VCL_BITMAPPALETTE_HXX + +#include <vcl/dllapi.h> +#include <vcl/BitmapColor.hxx> +#include <vcl/checksum.hxx> +#include <vector> + +class VCL_DLLPUBLIC BitmapPalette +{ + friend class SalBitmap; + friend class BitmapAccess; + +private: + + std::vector<BitmapColor> maBitmapColor; + +public: + + SAL_DLLPRIVATE const BitmapColor* ImplGetColorBuffer() const + { + return maBitmapColor.data(); + } + + SAL_DLLPRIVATE BitmapColor* ImplGetColorBuffer() + { + return maBitmapColor.data(); + } + + BitmapChecksum GetChecksum() const + { + return vcl_get_checksum(0, maBitmapColor.data(), maBitmapColor.size() * sizeof(BitmapColor)); + } + +public: + + BitmapPalette() + { + } + + BitmapPalette(sal_uInt16 nCount) + : maBitmapColor(nCount) + { + } + + bool operator==( const BitmapPalette& rBitmapPalette ) const + { + return maBitmapColor == rBitmapPalette.maBitmapColor; + } + + bool operator!=(const BitmapPalette& rBitmapPalette) const + { + return !( *this == rBitmapPalette ); + } + + bool operator!() const + { + return maBitmapColor.empty(); + } + + sal_uInt16 GetEntryCount() const + { + return maBitmapColor.size(); + } + + void SetEntryCount(sal_uInt16 nCount) + { + maBitmapColor.resize(nCount); + } + + const BitmapColor& operator[](sal_uInt16 nIndex) const + { + assert(nIndex < maBitmapColor.size() && "Palette index is out of range"); + return maBitmapColor[nIndex]; + } + + BitmapColor& operator[](sal_uInt16 nIndex) + { + assert(nIndex < maBitmapColor.size() && "Palette index is out of range"); + return maBitmapColor[nIndex]; + } + + sal_uInt16 GetBestIndex(const BitmapColor& rCol) const + { + sal_uInt16 nRetIndex = 0; + + if (!maBitmapColor.empty()) + { + for (size_t j = 0; j < maBitmapColor.size(); ++j) + { + if (rCol == maBitmapColor[j]) + { + return j; + } + } + + sal_uInt16 nLastErr = SAL_MAX_UINT16; + for (size_t i = 0; i < maBitmapColor.size(); ++i) + { + const sal_uInt16 nActErr = rCol.GetColorError(maBitmapColor[i]); + if ( nActErr < nLastErr ) + { + nLastErr = nActErr; + nRetIndex = i; + } + } + } + + return nRetIndex; + } + + /// Returns true if the palette is 8-bit grey palette. + bool IsGreyPalette8Bit() const; + /// Returns true if the paleete is a grey palette (may not be 8-bit). + bool IsGreyPaletteAny() const; +}; + +#endif // INCLUDED_VCL_BITMAPPALETTE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapPopArtFilter.hxx b/include/vcl/BitmapPopArtFilter.hxx new file mode 100644 index 000000000..e5733f733 --- /dev/null +++ b/include/vcl/BitmapPopArtFilter.hxx @@ -0,0 +1,33 @@ +/* -*- 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_BITMAPPOPARTILTER_HXX +#define INCLUDED_VCL_BITMAPPOPARTILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapPopArtFilter final : public BitmapFilter +{ +public: + BitmapPopArtFilter() {} + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + struct PopArtEntry + { + sal_uInt32 mnIndex; + sal_uInt32 mnCount; + }; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSeparableUnsharpenFilter.hxx b/include/vcl/BitmapSeparableUnsharpenFilter.hxx new file mode 100644 index 000000000..69dcfe3bf --- /dev/null +++ b/include/vcl/BitmapSeparableUnsharpenFilter.hxx @@ -0,0 +1,37 @@ +/* -*- 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_BITMAPSEPARABLEUNSHARPENFILTER_HXX +#define INCLUDED_VCL_BITMAPSEPARABLEUNSHARPENFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +/** Separable Unsharpen Mask filter is actually a subtracted blurred + image from the original image. + */ +class BitmapSeparableUnsharpenFilter final : public BitmapFilter +{ +public: + BitmapSeparableUnsharpenFilter(double fRadius) + : mfRadius(fRadius) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + double mfRadius; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSepiaFilter.hxx b/include/vcl/BitmapSepiaFilter.hxx new file mode 100644 index 000000000..3121987ed --- /dev/null +++ b/include/vcl/BitmapSepiaFilter.hxx @@ -0,0 +1,38 @@ +/* -*- 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_BITMAPSEPIAFILTER_HXX +#define INCLUDED_VCL_BITMAPSEPIAFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapSepiaFilter final : public BitmapFilter +{ +public: + BitmapSepiaFilter(double nSepiaPercent) + { + // clamp value to 100% + if (nSepiaPercent <= 100) + mnSepiaPercent = nSepiaPercent; + else + mnSepiaPercent = 100; + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt16 mnSepiaPercent; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSharpenFilter.hxx b/include/vcl/BitmapSharpenFilter.hxx new file mode 100644 index 000000000..079e1d418 --- /dev/null +++ b/include/vcl/BitmapSharpenFilter.hxx @@ -0,0 +1,24 @@ +/* -*- 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_BITMAPSHARPENFILTER_HXX +#define INCLUDED_VCL_BITMAPSHARPENFILTER_HXX + +#include <vcl/BitmapConvolutionMatrixFilter.hxx> + +class VCL_DLLPUBLIC BitmapSharpenFilter final : public BitmapConvolutionMatrixFilter +{ +public: + BitmapSharpenFilter(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSimpleColorQuantizationFilter.hxx b/include/vcl/BitmapSimpleColorQuantizationFilter.hxx new file mode 100644 index 000000000..7e306e051 --- /dev/null +++ b/include/vcl/BitmapSimpleColorQuantizationFilter.hxx @@ -0,0 +1,37 @@ +/* -*- 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_INCLUDE_VCL_BITMAPSIMPLECOLORQUANTIZATIONFILTER_HXX +#define INCLUDED_INCLUDE_VCL_BITMAPSIMPLECOLORQUANTIZATIONFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapSimpleColorQuantizationFilter final : public BitmapFilter +{ +public: + /** Reduce number of colors for the bitmap using the POPULAR algorithm + + @param nNewColorCount + Maximal number of bitmap colors after the reduce operation + */ + BitmapSimpleColorQuantizationFilter(sal_uInt16 nNewColorCount) + : mnNewColorCount(nNewColorCount) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt16 mnNewColorCount; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSmoothenFilter.hxx b/include/vcl/BitmapSmoothenFilter.hxx new file mode 100644 index 000000000..1a002c960 --- /dev/null +++ b/include/vcl/BitmapSmoothenFilter.hxx @@ -0,0 +1,34 @@ +/* -*- 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_BITMAPSMOOTHENFILTER_HXX +#define INCLUDED_VCL_BITMAPSMOOTHENFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapSmoothenFilter final : public BitmapFilter +{ +public: + BitmapSmoothenFilter(double fRadius) + : mfRadius(fRadius) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + double mfRadius; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSobelGreyFilter.hxx b/include/vcl/BitmapSobelGreyFilter.hxx new file mode 100644 index 000000000..31e56bf5a --- /dev/null +++ b/include/vcl/BitmapSobelGreyFilter.hxx @@ -0,0 +1,26 @@ +/* -*- 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_BITMAPSOBELGREYILTER_HXX +#define INCLUDED_VCL_BITMAPSOBELGREYILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class VCL_DLLPUBLIC BitmapSobelGreyFilter final : public BitmapFilter +{ +public: + BitmapSobelGreyFilter() {} + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapSolarizeFilter.hxx b/include/vcl/BitmapSolarizeFilter.hxx new file mode 100644 index 000000000..f3e36e10f --- /dev/null +++ b/include/vcl/BitmapSolarizeFilter.hxx @@ -0,0 +1,34 @@ +/* -*- 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_BITMAPSOLARIZEFILTER_HXX +#define INCLUDED_VCL_BITMAPSOLARIZEFILTER_HXX + +#include <vcl/BitmapFilter.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC BitmapSolarizeFilter final : public BitmapFilter +{ +public: + BitmapSolarizeFilter(double cSolarGreyThreshold) + : mcSolarGreyThreshold(cSolarGreyThreshold) + { + } + + virtual BitmapEx execute(BitmapEx const& rBitmapEx) const override; + +private: + sal_uInt8 mcSolarGreyThreshold; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx new file mode 100644 index 000000000..8c168b642 --- /dev/null +++ b/include/vcl/BitmapTools.hxx @@ -0,0 +1,89 @@ +/* -*- 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_BITMAP_TOOLS_HXX +#define INCLUDED_VCL_BITMAP_TOOLS_HXX + +#include <config_cairo_canvas.h> +#include <vcl/bitmapex.hxx> +#include <vcl/ImageTree.hxx> +#include <vcl/BitmapColor.hxx> +#if ENABLE_CAIRO_CANVAS +#include <vcl/cairo.hxx> +#endif +#include <basegfx/range/b2drectangle.hxx> +#include <o3tl/safeint.hxx> +#include <array> +#include <vcl/RawBitmap.hxx> + +class SvStream; +namespace basegfx { class B2DHomMatrix; } +namespace com::sun::star::geometry { struct IntegerRectangle2D; } + +namespace vcl::bitmap { + +typedef sal_uInt8 (*lookup_table)[256]; + +lookup_table VCL_DLLPUBLIC get_premultiply_table(); +lookup_table VCL_DLLPUBLIC get_unpremultiply_table(); + +sal_uInt8 unpremultiply(sal_uInt8 c, sal_uInt8 a); +sal_uInt8 premultiply(sal_uInt8 c, sal_uInt8 a); + +BitmapEx VCL_DLLPUBLIC loadFromName(const OUString& rFileName, const ImageLoadFlags eFlags = ImageLoadFlags::NONE); + +void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx, double fScaleFactor); + +/** Copy block of image data into the bitmap. + Assumes that the Bitmap has been constructed with the desired size. + + @param pData + The block of data to copy + @param nStride + The number of bytes in a scanline, must be >= (width * nBitCount / 8) +*/ +BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount ); + +BitmapEx VCL_DLLPUBLIC CreateFromData( RawBitmap && data ); + +#if ENABLE_CAIRO_CANVAS +VCL_DLLPUBLIC BitmapEx* CreateFromCairoSurface(Size size, cairo_surface_t* pSurface); +#endif + +VCL_DLLPUBLIC BitmapEx CanvasTransformBitmap( const BitmapEx& rBitmap, + const ::basegfx::B2DHomMatrix& rTransform, + ::basegfx::B2DRectangle const & rDestRect, + ::basegfx::B2DHomMatrix const & rLocalTransform ); + +VCL_DLLPUBLIC void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparence, float fTransparence, AlphaMask & rNewMask); + +VCL_DLLPUBLIC void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBitmap, BitmapEx & aBmpEx, basegfx::B2DPolyPolygon const & rClipPath); + +VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx); + +/** + * @param data will be filled with alpha data, if xBitmap is alpha/transparent image + * @param bHasAlpha will be set to true if resulting surface has alpha + **/ +VCL_DLLPUBLIC void CanvasCairoExtractBitmapData( BitmapEx const & rBmpEx, Bitmap & rBitmap, unsigned char*& data, bool& bHasAlpha, long& rnWidth, long& rnHeight ); + +VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > CanvasExtractBitmapData(BitmapEx const & rBitmapEx, const css::geometry::IntegerRectangle2D& rect); + +// helper to construct historical 8x8 bitmaps with two colors + +BitmapEx VCL_DLLPUBLIC createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack); +bool VCL_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, Color& o_rBack, Color& o_rFront); + +VCL_DLLPUBLIC bool convertBitmap32To24Plus8(BitmapEx const & rInput, BitmapEx & rResult); + +} // end vcl::bitmap + +#endif // INCLUDED_VCL_BITMAP_TOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ColorMask.hxx b/include/vcl/ColorMask.hxx new file mode 100644 index 000000000..8705cea60 --- /dev/null +++ b/include/vcl/ColorMask.hxx @@ -0,0 +1,207 @@ +/* -*- 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_COLORMASK_HXX +#define INCLUDED_VCL_COLORMASK_HXX + +#include <vcl/dllapi.h> +#include <vcl/BitmapColor.hxx> + +#define MASK_TO_COLOR( d_nVal, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_Col ) \ +const sal_uInt8 _def_cR = static_cast<sal_uInt8>( d_RS < 0 ? ( (d_nVal) & d_RM ) << -d_RS : ( (d_nVal) & d_RM ) >> d_RS ); \ +const sal_uInt8 _def_cG = static_cast<sal_uInt8>( d_GS < 0 ? ( (d_nVal) & d_GM ) << -d_GS : ( (d_nVal) & d_GM ) >> d_GS ); \ +const sal_uInt8 _def_cB = static_cast<sal_uInt8>( d_BS < 0 ? ( (d_nVal) & d_BM ) << -d_BS : ( (d_nVal) & d_BM ) >> d_BS ); \ +d_Col = BitmapColor( static_cast<sal_uInt8>( _def_cR | ( ( _def_cR & maR.mnOr ) >> maR.mnOrShift ) ), \ + static_cast<sal_uInt8>( _def_cG | ( ( _def_cG & maG.mnOr ) >> maG.mnOrShift ) ), \ + static_cast<sal_uInt8>( _def_cB | ( ( _def_cB & maB.mnOr ) >> maB.mnOrShift ) ) ); + + +#define COLOR_TO_MASK( d_rCol, d_RM, d_GM, d_BM, d_RS, d_GS, d_BS, d_ALPHA ) \ +( ( ( ( d_RS < 0 ) ? ( static_cast<sal_uInt32>((d_rCol).GetRed()) >> -d_RS ) : \ + ( static_cast<sal_uInt32>((d_rCol).GetRed()) << d_RS ) ) & d_RM ) | \ + ( ( ( d_GS < 0 ) ? ( static_cast<sal_uInt32>((d_rCol).GetGreen()) >> -d_GS ) : \ + ( static_cast<sal_uInt32>((d_rCol).GetGreen()) << d_GS ) ) & d_GM ) | \ + ( ( ( d_BS < 0 ) ? ( static_cast<sal_uInt32>((d_rCol).GetBlue()) >> -d_BS ) : \ + ( static_cast<sal_uInt32>((d_rCol).GetBlue()) << d_BS ) ) & d_BM ) | \ + d_ALPHA ) + + +struct VCL_DLLPUBLIC ColorMaskElement +{ + sal_uInt32 mnMask; + int mnShift; + int mnOrShift; + sal_uInt8 mnOr; + explicit ColorMaskElement(sal_uInt32 nMask = 0) + : mnMask(nMask) + , mnShift(0) + , mnOrShift(0) + , mnOr(0) + { + } + bool CalcMaskShift() + { + if (mnMask == 0) + return true; + + // from which bit starts the mask? + int nShift = 31; + + while( nShift >= 0 && !( mnMask & ( 1 << nShift ) ) ) + --nShift; + + mnShift = nShift - 7; + int nLen = 0; + + // XXX determine number of bits set => walk right until null + while( nShift >= 0 && ( mnMask & ( 1 << nShift ) ) ) + { + nShift--; + nLen++; + } + + if (nLen > 8) // mask length must be 8 bits or less + return false; + + mnOrShift = 8 - nLen; + mnOr = static_cast<sal_uInt8>( ( 0xFF >> nLen ) << mnOrShift ); + + return true; + } +}; + +class VCL_DLLPUBLIC ColorMask +{ + ColorMaskElement maR; + ColorMaskElement maG; + ColorMaskElement maB; + +public: + + ColorMask(const ColorMaskElement& rRedMask = ColorMaskElement(), + const ColorMaskElement& rGreenMask = ColorMaskElement(), + const ColorMaskElement& rBlueMask = ColorMaskElement()) + : maR(rRedMask) + , maG(rGreenMask) + , maB(rBlueMask) + { + } + + inline sal_uInt32 GetRedMask() const; + inline sal_uInt32 GetGreenMask() const; + inline sal_uInt32 GetBlueMask() const; + + inline void GetColorFor8Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const; + inline void SetColorFor8Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const; + + inline void GetColorFor16BitMSB( BitmapColor& rColor, const sal_uInt8* pPixel ) const; + inline void SetColorFor16BitMSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const; + inline void GetColorFor16BitLSB( BitmapColor& rColor, const sal_uInt8* pPixel ) const; + inline void SetColorFor16BitLSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const; + + inline void GetColorFor32Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const; + inline void GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, const sal_uInt8* pPixel ) const; + inline void SetColorFor32Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const; +}; + +inline sal_uInt32 ColorMask::GetRedMask() const +{ + return maR.mnMask; +} + +inline sal_uInt32 ColorMask::GetGreenMask() const +{ + return maG.mnMask; +} + +inline sal_uInt32 ColorMask::GetBlueMask() const +{ + return maB.mnMask; +} + +inline void ColorMask::GetColorFor8Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = *pPixel; + MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maR.mnShift, rColor ); +} + +inline void ColorMask::SetColorFor8Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const +{ + *pPixel = static_cast<sal_uInt8>(COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, 0/*nAlphaChannel*/ )); +} + +inline void ColorMask::GetColorFor16BitMSB( BitmapColor& rColor, const sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = pPixel[ 1 ] | ( static_cast<sal_uInt32>(pPixel[ 0 ]) << 8 ); + + MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor ); +} + +inline void ColorMask::SetColorFor16BitMSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const +{ + const sal_uInt16 nVal = static_cast<sal_uInt16>(COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, 0/*nAlphaChannel*/ )); + + pPixel[ 0 ] = static_cast<sal_uInt8>(nVal >> 8); + pPixel[ 1 ] = static_cast<sal_uInt8>(nVal); +} + +inline void ColorMask::GetColorFor16BitLSB( BitmapColor& rColor, const sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = pPixel[ 0 ] | ( static_cast<sal_uInt32>(pPixel[ 1 ]) << 8 ); + + MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor ); +} + +inline void ColorMask::SetColorFor16BitLSB( const BitmapColor& rColor, sal_uInt8* pPixel ) const +{ + const sal_uInt16 nVal = static_cast<sal_uInt16>(COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, 0/*nAlphaChannel*/ )); + + pPixel[ 0 ] = static_cast<sal_uInt8>(nVal); + pPixel[ 1 ] = static_cast<sal_uInt8>(nVal >> 8); +} + +inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, const sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = static_cast<sal_uInt32>(pPixel[ 0 ]) | ( static_cast<sal_uInt32>(pPixel[ 1 ]) << 8 ) | + ( static_cast<sal_uInt32>(pPixel[ 2 ]) << 16 ) | ( static_cast<sal_uInt32>(pPixel[ 3 ]) << 24 ); + + MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor ); +} + +inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, const sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = static_cast<sal_uInt32>(pPixel[ 0 ]) | ( static_cast<sal_uInt32>(pPixel[ 1 ]) << 8 ) | + ( static_cast<sal_uInt32>(pPixel[ 2 ]) << 16 ) | ( static_cast<sal_uInt32>(pPixel[ 3 ]) << 24 ); + rAlpha = static_cast<sal_uInt8>(nVal >> 24); + + MASK_TO_COLOR( nVal, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, rColor ); +} + +inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, sal_uInt8* pPixel ) const +{ + const sal_uInt32 nVal = COLOR_TO_MASK( rColor, maR.mnMask, maG.mnMask, maB.mnMask, maR.mnShift, maG.mnShift, maB.mnShift, 0/*nAlphaChannel*/ ); + pPixel[ 0 ] = static_cast<sal_uInt8>(nVal); + pPixel[ 1 ] = static_cast<sal_uInt8>( nVal >> 8 ); + pPixel[ 2 ] = static_cast<sal_uInt8>( nVal >> 16 ); + pPixel[ 3 ] = static_cast<sal_uInt8>( nVal >> 24 ); +} + +#endif // INCLUDED_VCL_COLORMASK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/EnumContext.hxx b/include/vcl/EnumContext.hxx new file mode 100644 index 000000000..3609640fe --- /dev/null +++ b/include/vcl/EnumContext.hxx @@ -0,0 +1,165 @@ +/* -*- 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_ENUMCONTEXT_HXX +#define INCLUDED_VCL_ENUMCONTEXT_HXX + +#include <vcl/dllapi.h> + +#include <rtl/ustring.hxx> + + +namespace vcl { + +class VCL_DLLPUBLIC EnumContext +{ +public: + enum class Application + { + Writer, + WriterGlobal, + WriterWeb, + WriterXML, + WriterForm, + WriterReport, + Calc, + Chart, + Draw, + Impress, + Formula, + Base, + + // For your convenience to avoid duplicate code in the common + // case that Draw and Impress use identical context configurations. + DrawImpress, + + // Also for your convenience for the different variants of Writer documents. + WriterVariants, + + // Used only by deck or panel descriptors. Matches any + // application. + Any, + + // Use this only in special circumstances. One might be the + // wish to disable a deck or panel during debugging. + NONE, + + LAST = Application::NONE + }; + enum class Context + { + ThreeDObject, + Annotation, + Auditing, + Axis, + Cell, + Chart, + ChartElements, + Draw, + DrawLine, + DrawPage, + DrawText, + EditCell, + ErrorBar, + Form, + Frame, + Graphic, + Grid, + HandoutPage, + MasterPage, + Media, + MultiObject, + NotesPage, + OLE, + OutlineText, + Pivot, + Printpreview, + Series, + SlidesorterPage, + Table, + Text, + TextObject, + Trendline, + + // Default context of an application. Do we need this? + Default, + + // Used only by deck or panel descriptors. Matches any context. + Any, + + // Special context name that is only used when a deck would + // otherwise be empty. + Empty, + + Unknown, + + LAST = Unknown + }; + + EnumContext(); + EnumContext ( + const Application eApplication, + const Context eContext); + + /** This variant of the GetCombinedContext() method treats some + application names as identical to each other. Replacements + made are: + Draw or Impress -> DrawImpress + Writer or WriterWeb -> WriterAndWeb + Use the Application::DrawImpress or Application::WriterAndWeb values in the CombinedEnumContext macro. + */ + sal_Int32 GetCombinedContext_DI() const; + + Application GetApplication_DI() const; + + bool operator == (const EnumContext& rOther) const; + bool operator != (const EnumContext& rOther) const; + + /** When two contexts are matched against each other, then + application or context name may have the wildcard value 'any'. + In order to prefer matches without wildcards over matches with + wildcards we introduce an integer evaluation for matches. + */ + const static sal_Int32 NoMatch; + const static sal_Int32 OptimalMatch; + + static Application GetApplicationEnum (const OUString& rsApplicationName); + static const OUString& GetApplicationName (const Application eApplication); + + static Context GetContextEnum (const OUString& rsContextName); + static const OUString& GetContextName (const Context eContext); + +private: + Application meApplication; + Context meContext; + + static void ProvideApplicationContainers(); + static void ProvideContextContainers(); + static void AddEntry (const OUString& rsName, const Application eApplication); + static void AddEntry (const OUString& rsName, const Context eContext); +}; + + +#define CombinedEnumContext(a,e) ((static_cast<sal_uInt16>(::vcl::EnumContext::a)<<16)\ + | static_cast<sal_uInt16>(::vcl::EnumContext::e)) + +} // end of namespace vcl + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/FilterConfigItem.hxx b/include/vcl/FilterConfigItem.hxx new file mode 100644 index 000000000..ae9e0f33c --- /dev/null +++ b/include/vcl/FilterConfigItem.hxx @@ -0,0 +1,90 @@ +/* -*- 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_FILTERCONFIGITEM_HXX +#define INCLUDED_VCL_FILTERCONFIGITEM_HXX + +#include <vcl/dllapi.h> + +#include <rtl/ustring.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.hxx> + +namespace com::sun::star::beans { class XPropertySet; } +namespace com::sun::star::task { class XStatusIndicator; } +namespace com::sun::star::uno { class Any; } +namespace com::sun::star::uno { class XInterface; } + +class VCL_DLLPUBLIC FilterConfigItem +{ + css::uno::Reference< css::uno::XInterface > xUpdatableView; + css::uno::Reference< css::beans::XPropertySet > xPropSet; + css::uno::Sequence< css::beans::PropertyValue > aFilterData; + + bool bModified; + + static bool ImplGetPropertyValue( css::uno::Any& rAny, + const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, + const OUString& rPropName ); + + void ImpInitTree( const OUString& rTree ); + + + static css::beans::PropertyValue* GetPropertyValue( + css::uno::Sequence< css::beans::PropertyValue >& rPropSeq, + const OUString& rName ); + static bool WritePropertyValue( + css::uno::Sequence< css::beans::PropertyValue >& rPropSeq, + const css::beans::PropertyValue& rPropValue ); + +public: + + FilterConfigItem( const OUString& rSubTree ); + FilterConfigItem( css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ); + FilterConfigItem( const OUString& rSubTree, css::uno::Sequence< css::beans::PropertyValue > const * pFilterData ); + /// Writes config in destructor + ~FilterConfigItem(); + /// Writes config and sets unmodified state again. + void WriteModifiedConfig(); + + // all read methods are trying to return values in following order: + // 1. FilterData PropertySequence + // 2. configuration + // 3. given default + bool ReadBool( const OUString& rKey, bool bDefault ); + sal_Int32 ReadInt32( const OUString& rKey, sal_Int32 nDefault ); + OUString + ReadString( const OUString& rKey, const OUString& rDefault ); + + // try to store to configuration + // and always stores into the FilterData sequence + void WriteBool( const OUString& rKey, bool bValue ); + void WriteInt32( const OUString& rKey, sal_Int32 nValue ); + + const css::uno::Sequence< css::beans::PropertyValue >& GetFilterData() const { return aFilterData;} + + // GetStatusIndicator is returning the "StatusIndicator" property of the FilterData sequence + css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator() const; +}; + +#endif // INCLUDED_VCL_FILTERCONFIGITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GestureEvent.hxx b/include/vcl/GestureEvent.hxx new file mode 100644 index 000000000..7b6f25719 --- /dev/null +++ b/include/vcl/GestureEvent.hxx @@ -0,0 +1,61 @@ +/* -*- 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_GESTUREEVENT_HXX +#define INCLUDED_VCL_GESTUREEVENT_HXX + +#include <vcl/dllapi.h> + +enum class GestureEventType +{ + PanningBegin, + PanningUpdate, + PanningEnd +}; + +enum class PanningOrientation +{ + Horizontal, + Vertical +}; + +class VCL_DLLPUBLIC GestureEvent +{ +public: + sal_Int32 mnX; + sal_Int32 mnY; + GestureEventType meEventType; + + sal_Int32 mnOffset; + PanningOrientation meOrientation; + + GestureEvent() + : mnX(0) + , mnY(0) + , meEventType(GestureEventType::PanningBegin) + , mnOffset(0) + , meOrientation(PanningOrientation::Horizontal) + { + } + + GestureEvent(sal_Int32 nX, sal_Int32 nY, GestureEventType eEventType, sal_Int32 nOffset, + PanningOrientation eOrientation) + : mnX(nX) + , mnY(nY) + , meEventType(eEventType) + , mnOffset(nOffset) + , meOrientation(eOrientation) + { + } +}; + +#endif // INCLUDED_VCL_GESTUREEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicExternalLink.hxx b/include/vcl/GraphicExternalLink.hxx new file mode 100644 index 000000000..ab9f2a69f --- /dev/null +++ b/include/vcl/GraphicExternalLink.hxx @@ -0,0 +1,31 @@ +/* -*- 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_GRAPHIC_EXTERNAL_LINK_HXX +#define INCLUDED_VCL_GRAPHIC_EXTERNAL_LINK_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> + +class VCL_DLLPUBLIC GraphicExternalLink +{ +public: + OUString msURL; + + GraphicExternalLink() {} + + GraphicExternalLink(OUString const& rURL) + : msURL(rURL) + { + } +}; + +#endif // INCLUDED_VCL_GRAPHIC_EXTERNAL_LINK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicLoader.hxx b/include/vcl/GraphicLoader.hxx new file mode 100644 index 000000000..5cca83a99 --- /dev/null +++ b/include/vcl/GraphicLoader.hxx @@ -0,0 +1,30 @@ +/* -*- 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_GRAPHIC_LOADER_HXX +#define INCLUDED_VCL_GRAPHIC_LOADER_HXX + +#include <vcl/graph.hxx> + +namespace weld +{ +class Window; +} + +namespace vcl +{ +namespace graphic +{ +Graphic VCL_DLLPUBLIC loadFromURL(OUString const& rURL, weld::Window* pParentWin = nullptr); +} +} // end vcl::graphic + +#endif // INCLUDED_VCL_GRAPHIC_TOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicNativeMetadata.hxx b/include/vcl/GraphicNativeMetadata.hxx new file mode 100644 index 000000000..3dbd7ff8a --- /dev/null +++ b/include/vcl/GraphicNativeMetadata.hxx @@ -0,0 +1,40 @@ +/* -*- 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 . + */ + +#pragma once + +#include <vcl/graph.hxx> +#include <tools/stream.hxx> + +class VCL_DLLPUBLIC GraphicNativeMetadata final +{ + sal_uInt16 mRotation; + +public: + GraphicNativeMetadata(); + ~GraphicNativeMetadata(); + + bool read(Graphic const& rGraphic); + bool read(SvStream& rStream); + + // counter-clock-wise rotation in permille + sal_uInt16 getRotation() const { return mRotation; } +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicNativeTransform.hxx b/include/vcl/GraphicNativeTransform.hxx new file mode 100644 index 000000000..b4d71f2d5 --- /dev/null +++ b/include/vcl/GraphicNativeTransform.hxx @@ -0,0 +1,43 @@ +/* -*- 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 . + */ + +#pragma once + +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <vcl/dllapi.h> + +class Graphic; + +class VCL_DLLPUBLIC GraphicNativeTransform final +{ + Graphic& mrGraphic; + + bool rotateBitmapOnly(sal_uInt16 aRotation); + void rotateJPEG(sal_uInt16 aRotation); + bool rotateGeneric(sal_uInt16 aRotation, const OUString& aType); + +public: + GraphicNativeTransform(Graphic& rGraphic); + ~GraphicNativeTransform(); + + void rotate(sal_uInt16 aRotation); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/GraphicObject.hxx b/include/vcl/GraphicObject.hxx new file mode 100644 index 000000000..5a4053fa6 --- /dev/null +++ b/include/vcl/GraphicObject.hxx @@ -0,0 +1,401 @@ +/* -*- 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_GRAPHICOBJECT_HXX +#define INCLUDED_VCL_GRAPHICOBJECT_HXX + +#include <memory> +#include <vcl/graph.hxx> +#include <vcl/dllapi.h> +#include <o3tl/typed_flags_set.hxx> + +namespace com::sun::star::graphic { class XGraphic; } + +// Adjustment defines +enum class GraphicAdjustmentFlags +{ + NONE = 0x00, + DRAWMODE = 0x01, + COLORS = 0x02, + MIRROR = 0x04, + ROTATE = 0x08, + TRANSPARENCY = 0x10, + ALL = 0x1f, +}; +namespace o3tl +{ + template<> struct typed_flags<GraphicAdjustmentFlags> : is_typed_flags<GraphicAdjustmentFlags, 0x1f> {}; +} + +enum class GraphicDrawMode +{ + Standard = 0, + Greys = 1, + Mono = 2, + Watermark = 3 +}; + +class VirtualDevice; +struct GrfSimpleCacheObj; +struct ImplTileInfo; + +class VCL_DLLPUBLIC GraphicAttr +{ +private: + + double mfGamma; + BmpMirrorFlags mnMirrFlags; + long mnLeftCrop; + long mnTopCrop; + long mnRightCrop; + long mnBottomCrop; + sal_uInt16 mnRotate10; + short mnContPercent; + short mnLumPercent; + short mnRPercent; + short mnGPercent; + short mnBPercent; + bool mbInvert; + sal_uInt8 mcTransparency; + GraphicDrawMode meDrawMode; + +public: + + GraphicAttr(); + + bool operator==( const GraphicAttr& rAttr ) const; + bool operator!=( const GraphicAttr& rAttr ) const { return !( *this == rAttr ); } + + void SetDrawMode( GraphicDrawMode eDrawMode ) { meDrawMode = eDrawMode; } + GraphicDrawMode GetDrawMode() const { return meDrawMode; } + + void SetMirrorFlags( BmpMirrorFlags nMirrFlags ) { mnMirrFlags = nMirrFlags; } + BmpMirrorFlags GetMirrorFlags() const { return mnMirrFlags; } + + void SetCrop( long nLeft_100TH_MM, long nTop_100TH_MM, long nRight_100TH_MM, long nBottom_100TH_MM ) + { + mnLeftCrop = nLeft_100TH_MM; mnTopCrop = nTop_100TH_MM; + mnRightCrop = nRight_100TH_MM; mnBottomCrop = nBottom_100TH_MM; + } + long GetLeftCrop() const { return mnLeftCrop; } + long GetTopCrop() const { return mnTopCrop; } + long GetRightCrop() const { return mnRightCrop; } + long GetBottomCrop() const { return mnBottomCrop; } + + void SetRotation( sal_uInt16 nRotate10 ) { mnRotate10 = nRotate10; } + sal_uInt16 GetRotation() const { return mnRotate10; } + + void SetLuminance( short nLuminancePercent ) { mnLumPercent = nLuminancePercent; } + short GetLuminance() const { return mnLumPercent; } + + void SetContrast( short nContrastPercent ) { mnContPercent = nContrastPercent; } + short GetContrast() const { return mnContPercent; } + + void SetChannelR( short nChannelRPercent ) { mnRPercent = nChannelRPercent; } + short GetChannelR() const { return mnRPercent; } + + void SetChannelG( short nChannelGPercent ) { mnGPercent = nChannelGPercent; } + short GetChannelG() const { return mnGPercent; } + + void SetChannelB( short nChannelBPercent ) { mnBPercent = nChannelBPercent; } + short GetChannelB() const { return mnBPercent; } + + void SetGamma( double fGamma ) { mfGamma = fGamma; } + double GetGamma() const { return mfGamma; } + + void SetInvert( bool bInvert ) { mbInvert = bInvert; } + bool IsInvert() const { return mbInvert; } + + void SetTransparency( sal_uInt8 cTransparency ) { mcTransparency = cTransparency; } + sal_uInt8 GetTransparency() const { return mcTransparency; } + + bool IsSpecialDrawMode() const { return( meDrawMode != GraphicDrawMode::Standard ); } + bool IsMirrored() const { return mnMirrFlags != BmpMirrorFlags::NONE; } + bool IsCropped() const + { + return( mnLeftCrop != 0 || mnTopCrop != 0 || + mnRightCrop != 0 || mnBottomCrop != 0 ); + } + bool IsRotated() const { return( ( mnRotate10 % 3600 ) != 0 ); } + bool IsTransparent() const { return( mcTransparency > 0 ); } + bool IsAdjusted() const + { + return( mnLumPercent != 0 || mnContPercent != 0 || mnRPercent != 0 || + mnGPercent != 0 || mnBPercent != 0 || mfGamma != 1.0 || mbInvert ); + } +}; + +class VCL_DLLPUBLIC GraphicObject +{ + friend class SdrGrafObj; + +private: + Graphic maGraphic; + GraphicAttr maAttr; + OUString maUserData; + std::unique_ptr<GrfSimpleCacheObj> mxSimpleCache; + + bool VCL_DLLPRIVATE ImplGetCropParams( + OutputDevice const * pOut, + Point& rPt, + Size& rSz, + const GraphicAttr* pAttr, + tools::PolyPolygon& rClipPolyPoly, + bool& bRectClipRegion + ) const; + + /** Render a given number of tiles in an optimized way + + This method recursively subdivides the tile rendering problem + in smaller parts, i.e. rendering output size x with few tiles + of size y, which in turn are generated from the original + bitmap in a recursive fashion. The subdivision size can be + controlled by the exponent argument, which specifies the + minimal number of smaller tiles used in one recursion + step. The resulting tile size is given as the integer number + of repetitions of the original bitmap along x and y. As the + exponent need not necessarily divide these numbers without + remainder, the repetition counts are effectively converted to + base-exponent numbers, where each place denotes the number of + times the corresponding tile size is rendered. + + @param rVDev + Virtual device to render everything into + + @param nNumTilesX + Number of original tiles to generate in x direction + + @param nNumTilesY + Number of original tiles to generate in y direction + + @param rTileSizePixel + Size in pixel of the original tile bitmap to render it in + + @param pAttr + Graphic attributes to be used for rendering + + @param nFlags + Graphic flags to be used for rendering + + @param rCurrPos + Current output point for this recursion level (should start with (0,0)) + + @return true, if everything was successfully rendered. + */ + bool VCL_DLLPRIVATE ImplRenderTempTile( + VirtualDevice& rVDev, + int nNumTilesX, + int nNumTilesY, + const Size& rTileSizePixel, + const GraphicAttr* pAttr + ); + + /// internally called by ImplRenderTempTile() + bool VCL_DLLPRIVATE ImplRenderTileRecursive( + VirtualDevice& rVDev, + int nExponent, + int nMSBFactor, + int nNumOrigTilesX, + int nNumOrigTilesY, + int nRemainderTilesX, + int nRemainderTilesY, + const Size& rTileSizePixel, + const GraphicAttr* pAttr, + ImplTileInfo& rTileInfo + ); + + bool VCL_DLLPRIVATE ImplDrawTiled( + OutputDevice* pOut, + const tools::Rectangle& rArea, + const Size& rSizePixel, + const Size& rOffset, + const GraphicAttr* pAttr, + int nTileCacheSize1D + ); + + bool VCL_DLLPRIVATE ImplDrawTiled( + OutputDevice& rOut, + const Point& rPos, + int nNumTilesX, + int nNumTilesY, + const Size& rTileSize, + const GraphicAttr* pAttr + ); + + void VCL_DLLPRIVATE ImplTransformBitmap( + BitmapEx& rBmpEx, + const GraphicAttr& rAttr, + const Size& rCropLeftTop, + const Size& rCropRightBottom, + const tools::Rectangle& rCropRect, + const Size& rDstSize, + bool bEnlarge + ) const; + +public: + GraphicObject(); + GraphicObject( const Graphic& rGraphic ); + GraphicObject( const GraphicObject& rCacheObj ); + ~GraphicObject(); + + GraphicObject& operator=( const GraphicObject& rCacheObj ); + bool operator==( const GraphicObject& rCacheObj ) const; + bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); } + + const Graphic& GetGraphic() const; + void SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj = nullptr); + void SetGraphic( const Graphic& rGraphic, const OUString& rLink ); + + /** Get graphic transformed according to given attributes + + This method returns a Graphic transformed, cropped and scaled + to the given parameters, ready to be rendered to printer or + display. The returned graphic has the same visual appearance + as if it had been drawn via GraphicObject::Draw() to a + specific output device. + + @param rDestSize + Desired output size in logical coordinates. The mapmode to + interpret these logical coordinates in is given by the second + parameter, rDestMap. + + @param rDestMap + Mapmode the output should be interpreted in. This is used to + interpret rDestSize, to set the appropriate PrefMapMode on the + returned Graphic, and to deal correctly with metafile graphics. + + @param rAttr + Graphic attributes used to transform the graphic. This + includes cropping, rotation, mirroring, and various color + adjustment parameters. + + @return the readily transformed Graphic + */ + Graphic GetTransformedGraphic( + const Size& rDestSize, + const MapMode& rDestMap, + const GraphicAttr& rAttr + ) const; + Graphic GetTransformedGraphic( const GraphicAttr* pAttr ) const; // TODO: Change to Impl + + void SetAttr( const GraphicAttr& rAttr ); + const GraphicAttr& GetAttr() const { return maAttr; } + + bool HasUserData() const { return !maUserData.isEmpty(); } + void SetUserData(); + void SetUserData( const OUString& rUserData ); + const OUString& GetUserData() const { return maUserData; } + + OString GetUniqueID() const; + + GraphicType GetType() const; + Size GetPrefSize() const; + MapMode GetPrefMapMode() const; + bool IsTransparent() const; + bool IsAnimated() const; + bool IsEPS() const; + + bool Draw( + OutputDevice* pOut, + const Point& rPt, + const Size& rSz, + const GraphicAttr* pAttr = nullptr + ); + + /** Draw the graphic repeatedly into the given output rectangle + + @param pOut + OutputDevice where the rendering should take place + + @param rArea + The output area that is filled with tiled instances of this graphic + + @param rSize + The actual size of a single tile + + @param rOffset + Offset from the left, top position of rArea, where to start + the tiling. The upper left corner of the graphic tilings will + virtually start at this position. Concretely, only that many + tiles are drawn to completely fill the given output area. + + @param nFlags + Optional rendering flags + + @param nTileCacheSize1D + Optional dimension of the generated cache tiles. The pOut sees + a number of tile draws, which have approximately + nTileCacheSize1D times nTileCacheSize1D bitmap sizes if the + tile bitmap is smaller. Otherwise, the tile is drawn as + is. This is useful if e.g. you want only a few, very large + bitmap drawings appear on the outdev. + */ + void DrawTiled( + OutputDevice* pOut, + const tools::Rectangle& rArea, + const Size& rSize, + const Size& rOffset, + int nTileCacheSize1D=128 + ); + + bool StartAnimation( + OutputDevice* pOut, + const Point& rPt, + const Size& rSz, + long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = nullptr + ); + + void StopAnimation( OutputDevice* pOut = nullptr, long nExtraData = 0 ); + + static bool isGraphicObjectUniqueIdURL(OUString const & rURL); + + // create CropScaling information + // fWidth, fHeight: object size + // f*Crop: crop values relative to original bitmap size + basegfx::B2DVector calculateCropScaling( + double fWidth, + double fHeight, + double fLeftCrop, + double fTopCrop, + double fRightCrop, + double fBottomCrop) const; +}; + +namespace vcl +{ +namespace graphic +{ + +// Will search an object ( e.g. a control ) for any 'ImageURL' or 'Graphic' +// properties and return graphics from the properties in a vector. ImageURL +// will be loaded from the URL. +// +// Note: this implementation will cater for XNameContainer objects and deep inspect any containers +// if they exist + +VCL_DLLPUBLIC void SearchForGraphics(css::uno::Reference<css::uno::XInterface> const & rxInterface, + std::vector<css::uno::Reference<css::graphic::XGraphic>> & raGraphicList); + +} +} // end namespace vcl::graphic + +#endif // INCLUDED_VCL_GRAPHICOBJECT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/IContext.hxx b/include/vcl/IContext.hxx new file mode 100644 index 000000000..6af9b20c4 --- /dev/null +++ b/include/vcl/IContext.hxx @@ -0,0 +1,48 @@ +/* -*- 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/. + */ + +#pragma once + +#include <vcl/EnumContext.hxx> +#include <vector> + +#include <algorithm> + +namespace vcl +{ + +class VCL_DLLPUBLIC IContext +{ +protected: + IContext() + { + maContext.push_back( vcl::EnumContext::Context::Any ); + } + +public: + void SetContext(const std::vector<vcl::EnumContext::Context>& aContext) + { + maContext = aContext; + } + + bool HasContext( const vcl::EnumContext::Context eContext ) const + { + auto aFind = std::find(maContext.begin(), maContext.end(), eContext); + if (aFind == maContext.end()) + return false; + return true; + } + +private: + std::vector<vcl::EnumContext::Context> maContext; +}; + +} // namespace vcl + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx new file mode 100644 index 000000000..68a573574 --- /dev/null +++ b/include/vcl/IDialogRenderable.hxx @@ -0,0 +1,47 @@ +/* -*- 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_IDIALOGRENDERABLE_HXX +#define INCLUDED_VCL_IDIALOGRENDERABLE_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> + +#include <rtl/ustring.hxx> + +#include <vector> + +class SfxItemSet; + +namespace vcl +{ + +typedef std::pair<const OString, const OString> LOKPayloadItem; + +typedef sal_uInt32 LOKWindowId; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ILibreOfficeKitNotifier +{ +public: + virtual ~ILibreOfficeKitNotifier(); + + /// Callbacks + virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, + const OUString& rAction, + const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0; + + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const = 0; +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_IDIALOGRENDERABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/IPrioritable.hxx b/include/vcl/IPrioritable.hxx new file mode 100644 index 000000000..55faf6431 --- /dev/null +++ b/include/vcl/IPrioritable.hxx @@ -0,0 +1,54 @@ +/* -*- 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_IPRIORITABLE_HXX +#define INCLUDED_VCL_IPRIORITABLE_HXX + +#include <vcl/dllapi.h> + +#define VCL_PRIORITY_DEFAULT -1 + +namespace vcl +{ + +class VCL_DLLPUBLIC IPrioritable +{ +protected: + IPrioritable() : m_nPriority(VCL_PRIORITY_DEFAULT) + { + } + +public: + virtual ~IPrioritable() + { + } + + int GetPriority() const + { + return m_nPriority; + } + + void SetPriority(int nPriority) + { + m_nPriority = nPriority; + } + + virtual void HideContent() = 0; + virtual void ShowContent() = 0; + virtual bool IsHidden() = 0; + +private: + int m_nPriority; +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_IPRIORITABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx new file mode 100644 index 000000000..9e995216e --- /dev/null +++ b/include/vcl/ITiledRenderable.hxx @@ -0,0 +1,315 @@ +/* -*- 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_ITILEDRENDERABLE_HXX +#define INCLUDED_VCL_ITILEDRENDERABLE_HXX + +#include <tools/gen.hxx> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <vcl/ptrstyle.hxx> +#include <vcl/vclptr.hxx> +#include <map> +#include <com/sun/star/datatransfer/XTransferable.hpp> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::datatransfer::clipboard { class XClipboard; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } +namespace com::sun::star::uno { template <typename > class Sequence; } +namespace vcl { class Window; } + +class VirtualDevice; + +namespace vcl +{ + /* + * Map directly to css cursor styles to avoid further mapping in the client. + * Gtk (via gdk_cursor_new_from_name) also supports the same css cursor styles. + * + * This was created partially with help of the mappings in gtkdata.cxx. + * The list is incomplete as some cursor style simply aren't supported + * by css, it might turn out to be worth mapping some of these missing cursors + * to available cursors? + */ + extern const std::map <PointerStyle, OString> gaLOKPointerMap; + + +class VCL_DLLPUBLIC ITiledRenderable +{ +public: + + typedef std::map<const OUString, OUString> StringMap; + + virtual ~ITiledRenderable(); + + /** + * Paint a tile to a given VirtualDevice. + * + * Output parameters are measured in pixels, tile parameters are in + * twips. + */ + virtual void paintTile( VirtualDevice &rDevice, + int nOutputWidth, + int nOutputHeight, + int nTilePosX, + int nTilePosY, + long nTileWidth, + long nTileHeight ) = 0; + + /** + * Get the document size in twips. + */ + virtual Size getDocumentSize() = 0; + + /** + * Set the document "part", i.e. slide for a slideshow, and + * tab for a spreadsheet. + */ + virtual void setPart( int ) {} + + /** + * Get the number of parts -- see setPart for further details. + */ + virtual int getParts() + { + return 1; + } + + /** + * Get the currently displayed/selected part -- see setPart for further + * details. + */ + virtual int getPart() + { + return 0; + } + + /** + * Get the name of the currently displayed part, i.e. sheet in a spreadsheet + * or slide in a presentation. + */ + virtual OUString getPartName(int) + { + return OUString(); + } + + /** + * Get the vcl::Window for the document being edited + */ + virtual VclPtr<vcl::Window> getDocWindow() = 0; + + /** + * Get the hash of the currently displayed part, i.e. sheet in a spreadsheet + * or slide in a presentation. + */ + virtual OUString getPartHash(int nPart) = 0; + + /// @see lok::Document::setPartMode(). + virtual void setPartMode(int) {} + + /** + * Setup various document properties that are needed for the document to + * be renderable via tiled rendering. + */ + virtual void initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) = 0; + + /** + * Posts a keyboard event on the document. + * + * @see lok::Document::postKeyEvent(). + */ + virtual void postKeyEvent(int nType, int nCharCode, int nKeyCode) = 0; + + /** + * Posts a mouse event on the document. + * + * @see lok::Document::postMouseEvent(). + */ + virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) = 0; + + /** + * Sets the start or end of a text selection. + * + * @see lok::Document::setTextSelection(). + */ + virtual void setTextSelection(int nType, int nX, int nY) = 0; + + /** + * Gets the selection as a transferable for later processing + */ + virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() = 0; + + /** + * Adjusts the graphic selection. + * + * @see lok::Document::setGraphicSelection(). + */ + virtual void setGraphicSelection(int nType, int nX, int nY) = 0; + + /** + * @see lok::Document::resetSelection(). + */ + virtual void resetSelection() = 0; + + /** + * @see lok::Document::getPartPageRectangles(). + */ + virtual OUString getPartPageRectangles() + { + return OUString(); + } + + /** + * Get position and content of row/column headers of Calc documents. + * + * @param rRectangle - if not empty, then limit the output only to the area of this rectangle + * @return a JSON describing position/content of rows/columns + */ + virtual OUString getRowColumnHeaders(const tools::Rectangle& /*rRectangle*/) + { + return OUString(); + } + + /** + * Get position and size of cell cursor in Calc - as JSON in the + * current' views' co-ordinate system. + * (This could maybe also be used for tables in Writer/Impress in future?) + */ + virtual OString getCellCursor() + { + return OString(); + } + + virtual PointerStyle getPointer() = 0; + + /// Sets the clipboard of the component. + virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) = 0; + + /// If the current contents of the clipboard is something we can paste. + virtual bool isMimeTypeSupported() = 0; + + /** + * Save the client's view so that we can compute the right zoom level + * for the mouse events. + * @param nTilePixelWidth - tile width in pixels + * @param nTilePixelHeight - tile height in pixels + * @param nTileTwipWidth - tile width in twips + * @param nTileTwipHeight - tile height in twips + */ + virtual void setClientZoom(int /*nTilePixelWidth*/, + int /*nTilePixelHeight*/, + int /*nTileTwipWidth*/, + int /*nTileTwipHeight*/) + {} + + /// @see lok::Document::setClientVisibleArea(). + virtual void setClientVisibleArea(const tools::Rectangle& /*rRectangle*/) + { + } + + /** + * Show/Hide a single row/column header outline for Calc documents. + * + * @param bColumn - if we are dealing with a column or row group + * @param nLevel - the level to which the group belongs + * @param nIndex - the group entry index + * @param bHidden - the new group state (collapsed/expanded) + */ + virtual void setOutlineState(bool /*bColumn*/, int /*nLevel*/, int /*nIndex*/, bool /*bHidden*/) + { + return; + } + + /// Implementation for + /// lok::Document::getCommandValues(".uno:AcceptTrackedChanges") when there + /// is no matching UNO API. + virtual OUString getTrackedChanges() + { + return OUString(); + } + + /// Implementation for + /// lok::Document::getCommandValues(".uno:TrackedChangeAuthors"). + virtual OUString getTrackedChangeAuthors() + { + return OUString(); + } + + /// Implementation for + /// lok::Document::getCommandValues(".uno:ViewAnnotations"); + virtual OUString getPostIts() + { + return OUString(); + } + + /// Implementation for + /// lok::Document::getCommandValues(".uno:ViewAnnotationsPosition"); + virtual OUString getPostItsPos() + { + return OUString(); + } + + /// Implementation for + /// lok::Document::getCommandValues(".uno:RulerState"); + virtual OUString getRulerState() + { + return OUString(); + } + + /* + * Used for sheets in spreadsheet documents, + * and slides in presentation documents. + */ + virtual OUString getPartInfo(int /*nPart*/) + { + return OUString(); + } + + /** + * Select/Unselect a document "part", i.e. slide for a slideshow, and + * tab for a spreadsheet(?). + * nSelect: 0 to deselect, 1 to select, and 2 to toggle. + */ + virtual void selectPart(int /*nPart*/, int /*nSelect*/) {} + + /** + * Move selected pages/slides to a new position. + * nPosition: the new position to move to. + * bDuplicate: to copy (true), or to move (false). + */ + virtual void moveSelectedParts(int /*nPosition*/, bool /*bDuplicate*/) {} + + /// @see lok::Document::completeFunction(). + virtual void completeFunction(const OUString& /*rFunctionName*/) + { + } + + /** + * It can happen that the underlying implementation is being disposed, but + * somebody is trying to access the data... + */ + virtual bool isDisposed() const + { + return false; + } + + /** + * Execute a form field event in the document. + * E.g. select an item from a drop down field's list. + */ + virtual void executeFromFieldEvent(const StringMap&) + { + } +}; +} // namespace vcl + +#endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/IconThemeInfo.hxx b/include/vcl/IconThemeInfo.hxx new file mode 100644 index 000000000..825a0e14c --- /dev/null +++ b/include/vcl/IconThemeInfo.hxx @@ -0,0 +1,99 @@ +/* -*- 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_ICONTHEMEINFO_HXX +#define INCLUDED_VCL_ICONTHEMEINFO_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <rtl/ustring.hxx> + +#include <vector> + +// forward declaration of unit test classes. Required for friend relationship. +class IconThemeInfoTest; +class IconThemeSelectorTest; +class IconThemeScannerTest; + +namespace vcl { + +/** This class provides information about an icon theme. + */ +class VCL_DLLPUBLIC IconThemeInfo { + +public: + + /** The name of the icon theme to use for high contrast mode */ + static const OUStringLiteral HIGH_CONTRAST_ID; + + /** Construct an IconThemeInfo from the URL to a file. + * This method will throw a std::runtime_error if the URL cannot be properly parsed. + * Check the URL with UrlCanBeParsed() first. + */ + IconThemeInfo(const OUString& urlToFile); + + const OUString& GetDisplayName() const {return mDisplayName;} + + const OUString& GetThemeId() const { return mThemeId; } + + const OUString& GetUrlToFile() const { return mUrlToFile; } + + /** Obtain the icon size by theme name. + * @internal + * It is not clear where this information belongs to. The sizes were hard-coded before they moved here. + * Maybe there is a way to determine the sizes from the icon theme packages. + */ + static Size SizeByThemeName(const OUString&); + + /** Check whether an IconThemeInfo can be constructed from a URL */ + static bool UrlCanBeParsed(const OUString& url); + + /** Find an icon theme by its id in a vector. + * Throws a runtime_error if the theme is not contained in the vector + */ + static const vcl::IconThemeInfo& + FindIconThemeById(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId); + + /** Check whether a theme with a specified id is in a vector of IconThemeInfo */ + static bool + IconThemeIsInVector(const std::vector<vcl::IconThemeInfo>& themes, const OUString& themeId); + +private: + /** private constructor for testing purposes only */ + IconThemeInfo(); + + /** Determine the icon theme name from the filename + * If the name has an underscore, the name is taken from the first underscore to the last dot, + * e.g., images_oxygen.zip becomes oxygen + * If the name does not have an underscore in it, the whole name until the last dot is returned, + * e.g. default.zip becomes default + */ + static OUString FileNameToThemeId(const OUString&); + + /** Creates the display name for the given id of a file. + * Currently, we only uppercase the id. + */ + static OUString ThemeIdToDisplayName(const OUString&); + + /** The name which is presented to the user */ + OUString mDisplayName; + /** The theme id. This id is used in ... to determine the file name */ + OUString mThemeId; + /** The url to the icon theme package */ + OUString mUrlToFile; + + friend class ::IconThemeInfoTest; + friend class ::IconThemeScannerTest; + friend class ::IconThemeSelectorTest; +}; + +} // namespace vcl + + +#endif // INCLUDED_VCL_ICONTHEMEINFO_HXX diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx new file mode 100644 index 000000000..85f05d774 --- /dev/null +++ b/include/vcl/ImageTree.hxx @@ -0,0 +1,88 @@ +/* -*- 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_INCLUDE_VCL_IMAGETREE_HXX +#define INCLUDED_INCLUDE_VCL_IMAGETREE_HXX + +#include <memory> +#include <sal/config.h> +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <o3tl/typed_flags_set.hxx> + +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +enum class ImageLoadFlags : sal_uInt16 +{ + NONE = 0, + IgnoreScalingFactor = 1, + IgnoreDarkTheme = 2, +}; + +namespace o3tl { +template<> struct typed_flags<ImageLoadFlags>: is_typed_flags<ImageLoadFlags, 0x3> {}; +} + +namespace com::sun::star::container { + class XNameAccess; +} + +class ImplImageTree; +class BitmapEx; +class SvMemoryStream; + +class ImageTree +{ +private: + std::unique_ptr<ImplImageTree> mpImplImageTree; + +public: + ImageTree(); + + VCL_DLLPUBLIC static ImageTree & get(); + + VCL_DLLPUBLIC OUString getImageUrl( + OUString const & name, OUString const & style, OUString const & lang); + + VCL_DLLPUBLIC std::shared_ptr<SvMemoryStream> getImageStream( + OUString const & rName, OUString const & rStyle, OUString const & rLang); + + VCL_DLLPUBLIC bool loadImage( + OUString const & name, OUString const & style, + BitmapEx & bitmap, bool localized, + const ImageLoadFlags eFlags = ImageLoadFlags::NONE); + + VCL_DLLPUBLIC bool loadImage( + OUString const & name, OUString const & style, + BitmapEx & bitmap, bool localized, + sal_Int32 nScalePercentage, + const ImageLoadFlags eFlags = ImageLoadFlags::NONE); + + VCL_DLLPUBLIC css::uno::Reference<css::container::XNameAccess> const & getNameAccess(); + + + /** a crude form of life cycle control (called from DeInitVCL; otherwise, + * if the ImplImageTree singleton were destroyed during exit that would + * be too late for the destructors of the bitmaps in maIconCache)*/ + VCL_DLLPUBLIC void shutdown(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/InterimItemWindow.hxx b/include/vcl/InterimItemWindow.hxx new file mode 100644 index 000000000..3ba842a3e --- /dev/null +++ b/include/vcl/InterimItemWindow.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/weld.hxx> + +class VCL_DLLPUBLIC InterimItemWindow : public Control +{ +public: + virtual ~InterimItemWindow() override; + virtual void dispose() override; + + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + virtual void GetFocus() override; + +protected: + InterimItemWindow(vcl::Window* pParent, const OUString& rUIXMLDescription, const OString& rID); + + // pass keystrokes from our child window through this to handle focus changes correctly + // returns true if keystroke is consumed + bool ChildKeyInput(const KeyEvent& rKEvt); + + std::unique_ptr<weld::Builder> m_xBuilder; + VclPtr<vcl::Window> m_xVclContentArea; + std::unique_ptr<weld::Container> m_xContainer; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/NotebookBarAddonsMerger.hxx b/include/vcl/NotebookBarAddonsMerger.hxx new file mode 100644 index 000000000..325a6d387 --- /dev/null +++ b/include/vcl/NotebookBarAddonsMerger.hxx @@ -0,0 +1,78 @@ +/* -*- 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_NOTEBOOKBARADDONSMERGER_HXX +#define INCLUDED_VCL_NOTEBOOKBARADDONSMERGER_HXX + +#include <vcl/builder.hxx> +#include <vcl/window.hxx> +#include <vcl/image.hxx> +#include <vcl/menu.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/uno/Sequence.h> +#include <vector> +#include <map> + +class Menu; + +struct NotebookBarAddonsItem +{ + Image aImage; + std::vector<Image> aImageValues; + std::vector<css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>>> aAddonValues; +}; + +struct AddonsParams +{ + OUString sImageId; + OUString sControlType; + sal_uInt16 nWidth; +}; + +struct AddonNotebookBarItem +{ + OUString sCommandURL; + OUString sLabel; + OUString sImageIdentifier; + OUString sTarget; + OUString sContext; + OUString sControlType; + sal_uInt16 nWidth; + OUString sStyle; +}; + +class NotebookBarAddonsMerger +{ +public: + NotebookBarAddonsMerger(); + ~NotebookBarAddonsMerger(); + static void MergeNotebookBarAddons(vcl::Window* pParent, + const VclBuilder::customMakeWidget& pFunction, + const css::uno::Reference<css::frame::XFrame>& rFrame, + const NotebookBarAddonsItem& aNotebookBarAddonsItem, + VclBuilder::stringmap& rVec); + static void MergeNotebookBarMenuAddons(Menu* pPopupMenu, sal_Int16 nItemId, + const OString& sItemIdName, + NotebookBarAddonsItem& aNotebookBarAddonsItem); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/NotebookbarContextControl.hxx b/include/vcl/NotebookbarContextControl.hxx new file mode 100644 index 000000000..ce557c549 --- /dev/null +++ b/include/vcl/NotebookbarContextControl.hxx @@ -0,0 +1,24 @@ +/* -*- 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_NOTEBOOKBARCONTEXTCONTROL_HXX +#define INCLUDED_VCL_NOTEBOOKBARCONTEXTCONTROL_HXX + +#include <vcl/EnumContext.hxx> + +class NotebookbarContextControl +{ +public: + virtual ~NotebookbarContextControl() {} + virtual void SetContext( vcl::EnumContext::Context eContext ) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/RawBitmap.hxx b/include/vcl/RawBitmap.hxx new file mode 100644 index 000000000..aeb5dec9f --- /dev/null +++ b/include/vcl/RawBitmap.hxx @@ -0,0 +1,65 @@ +/* -*- 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/. + */ + +#pragma once + +namespace vcl::bitmap +{ +/** + * Intended to be used to feed into CreateFromData to create a BitmapEx. RGB data format. + */ +class VCL_DLLPUBLIC RawBitmap +{ + friend BitmapEx VCL_DLLPUBLIC CreateFromData(RawBitmap&& rawBitmap); + std::unique_ptr<sal_uInt8[]> mpData; + Size maSize; + sal_uInt8 mnBitCount; + +public: + RawBitmap(Size const& rSize, sal_uInt8 nBitCount) + : maSize(rSize) + , mnBitCount(nBitCount) + { + assert(nBitCount == 24 || nBitCount == 32); + sal_Int32 nRowSize, nDataSize; + if (o3tl::checked_multiply<sal_Int32>(rSize.getWidth(), nBitCount / 8, nRowSize) + || o3tl::checked_multiply<sal_Int32>(nRowSize, rSize.getHeight(), nDataSize) + || nDataSize < 0) + { + throw std::bad_alloc(); + } + mpData.reset(new sal_uInt8[nDataSize]); + } + void SetPixel(long nY, long nX, Color nColor) + { + long p = (nY * maSize.getWidth() + nX) * (mnBitCount / 8); + mpData[p++] = nColor.GetRed(); + mpData[p++] = nColor.GetGreen(); + mpData[p++] = nColor.GetBlue(); + if (mnBitCount == 32) + mpData[p] = nColor.GetTransparency(); + } + Color GetPixel(long nY, long nX) const + { + long p = (nY * maSize.getWidth() + nX) * mnBitCount / 8; + if (mnBitCount == 24) + return Color(mpData[p], mpData[p + 1], mpData[p + 2]); + else + return Color(mpData[p + 3], mpData[p], mpData[p + 1], mpData[p + 2]); + } + // so we don't accidentally leave any code in that uses palette color indexes + void SetPixel(long nY, long nX, BitmapColor nColor) = delete; + long Height() { return maSize.Height(); } + long Width() { return maSize.Width(); } + sal_uInt8 GetBitCount() const { return mnBitCount; } +}; + +} // end vcl::bitmap + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/Scanline.hxx b/include/vcl/Scanline.hxx new file mode 100644 index 000000000..839130e38 --- /dev/null +++ b/include/vcl/Scanline.hxx @@ -0,0 +1,64 @@ +/* -*- 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_SCANLINE_HXX +#define INCLUDED_VCL_SCANLINE_HXX + +#include <o3tl/typed_flags_set.hxx> + +typedef sal_uInt8* Scanline; +typedef const sal_uInt8* ConstScanline; + +enum class ScanlineFormat { + NONE = 0x00000000, + + N1BitMsbPal = 0x00000001, + N1BitLsbPal = 0x00000002, + + N4BitMsnPal = 0x00000004, + N4BitLsnPal = 0x00000008, + + N8BitPal = 0x00000010, + N8BitTcMask = 0x00000020, + + N24BitTcBgr = 0x00000100, + N24BitTcRgb = 0x00000200, + + N32BitTcAbgr = 0x00000800, + N32BitTcArgb = 0x00001000, + N32BitTcBgra = 0x00002000, + N32BitTcRgba = 0x00004000, + N32BitTcMask = 0x00008000, + + TopDown = 0x00010000 // scanline adjustment +}; + +namespace o3tl +{ + template<> struct typed_flags<ScanlineFormat> : is_typed_flags<ScanlineFormat, 0x0001fb3f> {}; +} + +inline ScanlineFormat RemoveScanline(ScanlineFormat nFormat) +{ + return nFormat & ~ScanlineFormat::TopDown; +} + +#endif // INCLUDED_VCL_SCANLINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/TaskStopwatch.hxx b/include/vcl/TaskStopwatch.hxx new file mode 100644 index 000000000..25daf9237 --- /dev/null +++ b/include/vcl/TaskStopwatch.hxx @@ -0,0 +1,123 @@ +/* -*- 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_TASK_STOPWATCH_HXX +#define INCLUDED_VCL_TASK_STOPWATCH_HXX + +#include <tools/time.hxx> +#include <vcl/dllapi.h> +#include <vcl/inputtypes.hxx> +#include <vcl/svapp.hxx> + +/** + * Helper class primary used to track time of long running iterating tasks. + * + * Normally it should be sufficient to instantiate the watch object before + * starting the iteration and query continueIter() at the end of each. + * + * Called Stopwatch, because there is already a Timer class in the Scheduler. + * + * TODO: merge into the general Scheduler, so this can also be used to track + * Task runtimes in a more general way. + * TODO: handle fast iterations, where continueIter is called multiple times + * per tick, by counting the iterations per tick and use that for approximation. + **/ +class VCL_DLLPUBLIC TaskStopwatch +{ + static constexpr VclInputFlags eDefaultInputStop = VCL_INPUT_ANY & ~VclInputFlags::TIMER; + static constexpr unsigned int nDefaultTimeSlice = 50; + static unsigned int m_nTimeSlice; + + sal_uInt64 m_nStartTicks; + sal_uInt64 m_nIterStartTicks; + bool m_bConsiderLastIterTime; + VclInputFlags m_eInputStop; + + bool nextIter(bool bQueryOnly) + { + sal_uInt64 nCurTicks = tools::Time::GetSystemTicks(); + // handle system ticks wrap as exceeded time slice + if (nCurTicks < m_nStartTicks) + return false; + + if (!bQueryOnly && m_bConsiderLastIterTime) + { + // based on the last iter runtime, we don't expect to finish in time + // m_nTimeSlice < (nCurTicks - m_nStartTicks) + (nCurTicks - m_nIterStartTicks) + if (m_nTimeSlice < 2 * nCurTicks - m_nIterStartTicks - m_nStartTicks) + return false; + } + // time slice exceeded + else if (m_nTimeSlice < nCurTicks - m_nStartTicks) + return false; + + if (!bQueryOnly) + m_nIterStartTicks = nCurTicks; + + return !Application::AnyInput(m_eInputStop); + } + +public: + /** + * Per default the watch considers the last iter time when asking for an + * other iteration, so considers Scheduler::acceptableTaskTime as a + * maximum value. + * + * If you already know your iter time vary in a large range, consider + * setting bConciderLastIterTime to false, so Scheduler::acceptableTaskTime + * will be used as a minimum time slot. + **/ + TaskStopwatch(bool bConciderLastIterTime = true) + : m_nStartTicks(tools::Time::GetSystemTicks()) + , m_nIterStartTicks(m_nStartTicks) + , m_bConsiderLastIterTime(bConciderLastIterTime) + , m_eInputStop(eDefaultInputStop) + { + } + + /** + * Returns true, if the time slot is already exceeded + **/ + bool exceededRuntime() { return !nextIter(true); } + + /** + * Returns true, if another iteration will probably pass in the time slot + **/ + bool continueIter() { return nextIter(false); } + + /** + * Reset the stopwatch + **/ + void reset() + { + m_nStartTicks = tools::Time::GetSystemTicks(); + m_nIterStartTicks = m_nStartTicks; + } + + /** + * Sets the input events, which should also "exceed" the stopwatch. + * + * Per default this ignores the VclInputFlags::TIMER. + */ + void setInputStop(VclInputFlags eInputStop = eDefaultInputStop) { m_eInputStop = eInputStop; } + VclInputFlags inputStop() const { return m_eInputStop; } + + /** + * Sets the time considered the acceptable maximum for a task to run + * + * This is an orientation for long time background jobs to yield to + * the scheduler, so Idle task don't starve each other too much. + **/ + static unsigned int timeSlice() { return m_nTimeSlice; } + static void setTimeSlice(unsigned int nTimeSlice) { m_nTimeSlice = nTimeSlice; } +}; + +#endif // INCLUDED_VCL_TASK_STOPWATCH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx new file mode 100644 index 000000000..1c8d4f968 --- /dev/null +++ b/include/vcl/abstdlg.hxx @@ -0,0 +1,197 @@ +/* -*- 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_ABSTDLG_HXX +#define INCLUDED_VCL_ABSTDLG_HXX + +#include <sal/types.h> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <vcl/vclptr.hxx> +#include <vcl/vclreferencebase.hxx> +#include <vector> +#include <functional> +#include <memory> + +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +namespace com::sun::star::frame { class XModel; } + +class Dialog; +class BitmapEx; +class DiagramDataInterface; +namespace weld +{ + class Dialog; + class DialogController; + class Window; +} + +/** +* Some things multiple-inherit from VclAbstractDialog and OutputDevice, +* so we need to use virtual inheritance to keep the referencing counting +* OK. +*/ +class VCL_DLLPUBLIC VclAbstractDialog : public virtual VclReferenceBase +{ +protected: + virtual ~VclAbstractDialog() override; +public: + virtual short Execute() = 0; + + struct AsyncContext { + // for the case where the owner is the dialog itself, and the dialog is an unwelded VclPtr based dialog + VclPtr<VclReferenceBase> mxOwner; + // for the case where the dialog is welded, and owned by a DialogController + std::shared_ptr<weld::DialogController> mxOwnerDialogController; + // for the case where the dialog is welded, and is running async without a DialogController + std::shared_ptr<weld::Dialog> mxOwnerSelf; + std::function<void(sal_Int32)> maEndDialogFn; + bool isSet() const { return !!maEndDialogFn; } + }; + + bool StartExecuteAsync(const std::function<void(sal_Int32)> &rEndDialogFn) + { + AsyncContext aCtx; + aCtx.mxOwner = this; + aCtx.maEndDialogFn = rEndDialogFn; + return StartExecuteAsync(aCtx); + } + + /// Commence execution of a modal dialog. + virtual bool StartExecuteAsync(AsyncContext &); + + // Screenshot interface + virtual std::vector<OString> getAllPageUIXMLDescriptions() const; + virtual bool selectPageByUIXMLDescription(const OString& rUIXMLDescription); + virtual BitmapEx createScreenshot() const; + virtual OString GetScreenshotId() const { return OString(); }; +}; + +class VCL_DLLPUBLIC VclAbstractTerminatedDialog : public VclAbstractDialog +{ +protected: + virtual ~VclAbstractTerminatedDialog() override = default; +public: + virtual void EndDialog(sal_Int32 nResult) = 0; +}; + +class VCL_DLLPUBLIC AbstractPasswordToOpenModifyDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractPasswordToOpenModifyDialog() override = default; +public: + virtual OUString GetPasswordToOpen() const = 0; + virtual OUString GetPasswordToModify() const = 0; + virtual bool IsRecommendToOpenReadonly() const = 0; +}; + +class VCL_DLLPUBLIC AbstractScreenshotAnnotationDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractScreenshotAnnotationDlg() override = default; +}; + +class VCL_DLLPUBLIC AbstractSignatureLineDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractSignatureLineDialog() override = default; +}; + +class VCL_DLLPUBLIC AbstractSignSignatureLineDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractSignSignatureLineDialog() override = default; +}; + +class VCL_DLLPUBLIC AbstractQrCodeGenDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractQrCodeGenDialog() override = default; +}; + +class VCL_DLLPUBLIC AbstractAboutDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractAboutDialog() override = default; +}; + +class VCL_DLLPUBLIC AbstractTipOfTheDayDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractTipOfTheDayDialog() override = default; +}; + +/** Edit Diagram dialog */ +class VCL_DLLPUBLIC AbstractDiagramDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractDiagramDialog() override = default; +}; + +class VCL_DLLPUBLIC VclAbstractDialogFactory +{ +public: + virtual ~VclAbstractDialogFactory(); // needed for export of vtable + static VclAbstractDialogFactory* Create(); + // The Id is an implementation detail of the factory + virtual VclPtr<VclAbstractDialog> CreateVclDialog(weld::Window* pParent, sal_uInt32 nId) = 0; + + // creates instance of PasswordToOpenModifyDialog from cui + virtual VclPtr<AbstractPasswordToOpenModifyDialog> CreatePasswordToOpenModifyDialog(weld::Window * pParent, sal_uInt16 nMaxPasswdLen, bool bIsPasswordToModify) = 0; + + // creates instance of SignatureDialog from cui + virtual VclPtr<AbstractSignatureLineDialog> + CreateSignatureLineDialog(weld::Window* pParent, + const css::uno::Reference<css::frame::XModel> xModel, + bool bEditExisting) + = 0; + + // creates instance of SignSignatureDialog from cui + virtual VclPtr<AbstractSignSignatureLineDialog> + CreateSignSignatureLineDialog(weld::Window* pParent, + const css::uno::Reference<css::frame::XModel> xModel) + = 0; + + // creates instance of QrCodeDialog from cui + virtual VclPtr<AbstractQrCodeGenDialog> + CreateQrCodeGenDialog(weld::Window* pParent, + const css::uno::Reference<css::frame::XModel> xModel, + bool bEditExisting) + = 0; + + // creates instance of ScreenshotAnnotationDlg from cui + virtual VclPtr<AbstractScreenshotAnnotationDlg> CreateScreenshotAnnotationDlg( + weld::Dialog& rParentDialog) = 0; + + // create about dialog + virtual VclPtr<AbstractAboutDialog> + CreateAboutDialog(weld::Window* pParent) = 0; + + // create info dialog to show tip-of-the-day + virtual VclPtr<AbstractTipOfTheDayDialog> + CreateTipOfTheDayDialog(weld::Window* pParent) = 0; + + virtual VclPtr<AbstractDiagramDialog> CreateDiagramDialog( + weld::Window* pParent, + std::shared_ptr<DiagramDataInterface> pDiagramData) = 0; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/accel.hxx b/include/vcl/accel.hxx new file mode 100644 index 000000000..e5eca0602 --- /dev/null +++ b/include/vcl/accel.hxx @@ -0,0 +1,86 @@ +/* -*- 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_ACCEL_HXX +#define INCLUDED_VCL_ACCEL_HXX + +#include <config_options.h> +#include <tools/link.hxx> +#include <vcl/keycod.hxx> +#include <vcl/dllapi.h> +#include <memory> + +class ImplAccelData; +class ImplAccelEntry; +class CommandEvent; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) Accelerator +{ + friend class ImplAccelManager; + +private: + std::unique_ptr<ImplAccelData> mpData; + Link<Accelerator&,void> maActivateHdl; + Link<Accelerator&,void> maSelectHdl; + + // Will be set by AcceleratorManager + sal_uInt16 mnCurId; + bool* mpDel; + + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplCopyData( ImplAccelData& rAccelData ); + SAL_DLLPRIVATE void ImplDeleteData(); + SAL_DLLPRIVATE void ImplInsertAccel( + sal_uInt16 nItemId, + const vcl::KeyCode& rKeyCode, + bool bEnable, + Accelerator* pAutoAccel ); + + SAL_DLLPRIVATE ImplAccelEntry* + ImplGetAccelData( const vcl::KeyCode& rKeyCode ) const; + +public: + Accelerator(); + Accelerator( const Accelerator& rAccel ); + ~Accelerator(); + + void Activate(); + void Select(); + + void InsertItem( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); + + sal_uInt16 GetCurItemId() const { return mnCurId; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + + Accelerator* GetAccel( sal_uInt16 nItemId ) const; + + void SetActivateHdl( const Link<Accelerator&,void>& rLink ) { maActivateHdl = rLink; } + void SetSelectHdl( const Link<Accelerator&,void>& rLink ) { maSelectHdl = rLink; } + + Accelerator& operator=( const Accelerator& rAccel ); + + static bool ToggleMnemonicsOnHierarchy(const CommandEvent& rCEvent, const vcl::Window *pWindow); + static void GenerateAutoMnemonicsOnHierarchy(const vcl::Window* pWindow); +}; + +#endif // INCLUDED_VCL_ACCEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/accessiblefactory.hxx b/include/vcl/accessiblefactory.hxx new file mode 100644 index 000000000..5769fc818 --- /dev/null +++ b/include/vcl/accessiblefactory.hxx @@ -0,0 +1,168 @@ +/* -*- 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_ACCESSIBLEFACTORY_HXX +#define INCLUDED_VCL_ACCESSIBLEFACTORY_HXX + +#include <vcl/AccessibleBrowseBoxObjType.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +#include <salhelper/simplereferenceobject.hxx> +#include <tools/gen.hxx> + +namespace com::sun::star { + namespace accessibility { + class XAccessible; + class XAccessibleContext; + } + namespace awt { + class XWindow; + } +} + +namespace vcl { class IAccessibleBrowseBox; } +namespace vcl { class IAccessibleTabListBox; } +namespace vcl { class IAccessibleTableProvider; } + +class SvHeaderTabListBox; +class SvtIconChoiceCtrl; +class TabBar; +class SvTreeListBox; +class VCLXWindow; +class TextEngine; +class TextView; + +namespace vcl +{ + namespace table + { + class IAccessibleTable; + class IAccessibleTableControl; + } + + /** a function which is able to create a factory for the standard Accessible/Context + components needed for standard toolkit controls + + The returned pointer denotes an instance of the IAccessibleFactory, which has been acquired + <em>once</em>. The caller is responsible for holding this reference as long as it needs the + factory, and release it afterwards. + */ + typedef void* (* GetSvtAccessibilityComponentFactory)( ); + + + //= IAccessibleFactory + + class IAccessibleFactory : public virtual ::salhelper::SimpleReferenceObject + { + public: + virtual vcl::IAccessibleTabListBox* + createAccessibleTabListBox( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + SvHeaderTabListBox& rBox + ) const = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleTreeListBox( + SvTreeListBox& _rListBox, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent + ) const = 0; + virtual vcl::IAccessibleBrowseBox* + createAccessibleBrowseBox( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox + ) const = 0; + virtual table::IAccessibleTableControl* + createAccessibleTableControl( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + table::IAccessibleTable& _rTable + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleIconChoiceCtrl( + SvtIconChoiceCtrl& _rIconCtrl, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleTabBar( + TabBar& _rTabBar + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + createAccessibleTextWindowContext( + VCLXWindow* pVclXWindow, TextEngine& rEngine, TextView& rView + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxHeaderBar( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + vcl::IAccessibleTableProvider& _rOwningTable, + vcl::AccessibleBrowseBoxObjType _eObjType + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxTableCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowId, + sal_uInt16 _nColId, + sal_Int32 _nOffset + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleBrowseBoxHeaderCell( + sal_Int32 _nColumnRowId, + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + vcl::AccessibleBrowseBoxObjType _eObjType + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createAccessibleCheckBoxCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + const TriState& _eState, + bool _bIsTriState + ) const = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > + createEditBrowseBoxTableCellAccess( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + const css::uno::Reference< css::accessibility::XAccessible >& _rxControlAccessible, + const css::uno::Reference< css::awt::XWindow >& _rxFocusWindow, + vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos + ) const = 0; + + protected: + virtual ~IAccessibleFactory() override {} + }; + +} // namespace vcl + + +#endif // INCLUDED_VCL_ACCESSIBLEFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/accessibletable.hxx b/include/vcl/accessibletable.hxx new file mode 100644 index 000000000..88b1890f2 --- /dev/null +++ b/include/vcl/accessibletable.hxx @@ -0,0 +1,174 @@ +/* -*- 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_ACCESSIBLETABLE_HXX +#define INCLUDED_VCL_ACCESSIBLETABLE_HXX + +#include <tools/gen.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +namespace com::sun::star::accessibility { class XAccessible; } +namespace utl { class AccessibleStateSetHelper; } +namespace vcl { class Window; } + +namespace vcl::table +{ + +typedef sal_Int32 RowPos; + +enum AccessibleTableControlObjType +{ + TCTYPE_GRIDCONTROL, /// The GridControl itself. + TCTYPE_TABLE, /// The data table. + TCTYPE_ROWHEADERBAR, /// The row header bar. + TCTYPE_COLUMNHEADERBAR, /// The horizontal column header bar. + TCTYPE_TABLECELL, /// A cell of the data table. + TCTYPE_ROWHEADERCELL, /// A cell of the row header bar. + TCTYPE_COLUMNHEADERCELL, /// A cell of the column header bar. +}; + + +/** This abstract class provides methods to implement an accessible table object. +*/ +class IAccessibleTable +{ +public: + /** @return The position of the current row. */ + virtual sal_Int32 GetCurrentRow() const = 0; + /** @return The position of the current column. */ + virtual sal_Int32 GetCurrentColumn() const = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex )= 0; + virtual OUString GetAccessibleObjectName(AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const= 0; + virtual void GoToCell( sal_Int32 _nColumnPos, sal_Int32 _nRow )= 0; + virtual bool HasColHeader() = 0; + virtual bool HasRowHeader() = 0; + + /** return the description of the specified object. + @param eObjType + The type to ask for + @return + The description of the specified object. + */ + virtual OUString GetAccessibleObjectDescription(AccessibleTableControlObjType eObjType) const= 0; + + /** Fills the StateSet with all states (except DEFUNC and SHOWING, done by + the accessible object), depending on the specified object type. */ + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& rStateSet, + AccessibleTableControlObjType eObjType ) const= 0; + + // Window + virtual tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const = 0; + virtual void GrabFocus()= 0; + virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible()= 0; + virtual vcl::Window* GetAccessibleParentWindow() const= 0; + virtual vcl::Window* GetWindowInstance()= 0; + virtual sal_Int32 GetAccessibleControlCount() const = 0; + virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint )= 0; + virtual long GetRowCount() const= 0; + virtual long GetColumnCount() const= 0; + virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint )= 0; + virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar ) = 0; + virtual tools::Rectangle calcHeaderCellRect( bool _bColHeader, sal_Int32 _nPos ) = 0; + virtual tools::Rectangle calcTableRect() = 0; + virtual tools::Rectangle calcCellRect( sal_Int32 _nRowPos, sal_Int32 _nColPos ) = 0; + virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)= 0; + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)= 0; + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const= 0; + virtual OUString GetRowName(sal_Int32 _nIndex) const = 0; + virtual OUString GetColumnName( sal_Int32 _nIndex ) const = 0; + virtual OUString GetAccessibleCellText(sal_Int32 _nRowPos, sal_Int32 _nColPos) const = 0; + + virtual sal_Int32 GetSelectedRowCount() const = 0; + virtual sal_Int32 GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const = 0; + virtual bool IsRowSelected( sal_Int32 const i_rowIndex ) const = 0; + virtual void SelectRow( sal_Int32 const i_rowIndex, bool const i_select ) = 0; + virtual void SelectAllRows( bool const i_select ) = 0; + +protected: + ~IAccessibleTable() {} +}; + + +/** interface for an implementation of a table control's Accessible component +*/ +class IAccessibleTableControl +{ +public: + /** returns the XAccessible object itself + + The reference returned here can be used to control the life time of the + IAccessibleTableImplementation object. + + The returned reference is guaranteed to not be <NULL/>. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getMyself() = 0; + + /** disposes the accessible implementation, so that it becomes defunc + */ + virtual void DisposeAccessImpl() = 0; + + /** checks whether the accessible implementation, and its context, are still alive + @return <TRUE/>, if the object is not disposed or disposing. + */ + virtual bool isAlive() const = 0; + + /** commits the event at all listeners of the cell + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + virtual void commitCellEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue + ) = 0; + /** commits the event at all listeners of the table + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + virtual void commitTableEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue + ) = 0; + + ///** Commits an event to all listeners. */ + virtual void commitEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue + ) = 0; + +protected: + ~IAccessibleTableControl() {} +}; + +} // namespace vcl::table + +#endif // INCLUDED_VCL_ACCESSIBLETABLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/accessibletableprovider.hxx b/include/vcl/accessibletableprovider.hxx new file mode 100644 index 000000000..ff24c98b0 --- /dev/null +++ b/include/vcl/accessibletableprovider.hxx @@ -0,0 +1,233 @@ +/* -*- 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_ACCESSIBLETABLEPROVIDER_HXX +#define INCLUDED_VCL_ACCESSIBLETABLEPROVIDER_HXX + +#include <vcl/AccessibleBrowseBoxObjType.hxx> +#include <vcl/outdev.hxx> + +namespace com::sun::star::accessibility { class XAccessible; } +namespace utl { class AccessibleStateSetHelper; } + +namespace vcl +{ + +#define OFFSET_DEFAULT (sal_Int32(-1)) +#define OFFSET_NONE (sal_Int32(0)) + +enum AccessibleTableChildIndex +{ + /** Child index of the column header bar (first row). Exists always. */ + BBINDEX_COLUMNHEADERBAR = 0, + /** Child index of the row header bar ("handle column"). Exists always. */ + BBINDEX_ROWHEADERBAR = 1, + /** Child index of the data table. */ + BBINDEX_TABLE = 2, + /** Child index of the first additional control. */ + BBINDEX_FIRSTCONTROL = 3 +}; + + +/** This abstract class provides methods to implement an accessible table object. +*/ +class IAccessibleTableProvider +{ +public: + /** @return The count of the rows. */ + virtual long GetRowCount() const = 0; + /** @return The count of the columns. */ + virtual sal_uInt16 GetColumnCount() const = 0; + + /** @return The position of the current row. */ + virtual sal_Int32 GetCurrRow() const = 0; + /** @return The position of the current column. */ + virtual sal_uInt16 GetCurrColumn() const = 0; + + /** @return The description of a row. + @param _nRow The row which description is in demand. */ + virtual OUString GetRowDescription( sal_Int32 _nRow ) const = 0; + /** @return The description of a column. + @param _nColumn The column which description is in demand. */ + virtual OUString GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0; + + /** @return <TRUE/>, if the object has a row header. */ + virtual bool HasRowHeader() const = 0; //GetColumnId + virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) = 0; + + virtual void SetNoSelection() = 0; + virtual void SelectAll() = 0; + virtual void SelectRow( long _nRow, bool _bSelect = true, bool bExpand = true ) = 0; + virtual void SelectColumn( sal_uInt16 _nColumnPos, bool _bSelect = true ) = 0; + virtual sal_Int32 GetSelectedRowCount() const = 0; + virtual sal_Int32 GetSelectedColumnCount() const = 0; + /** @return <TRUE/>, if the row is selected. */ + virtual bool IsRowSelected( long _nRow ) const = 0; + virtual bool IsColumnSelected( long _nColumnPos ) const = 0; + virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const = 0; + virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const = 0; + + /** @return <TRUE/>, if the cell is visible. */ + virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const = 0; + virtual OUString GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const = 0; + + virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar, bool _bOnScreen = true ) = 0; + virtual tools::Rectangle calcTableRect( bool _bOnScreen = true ) = 0; + virtual tools::Rectangle GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumnPos, bool _bIsHeader, bool _bOnScreen = true ) = 0; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) = 0; + + virtual sal_Int32 GetAccessibleControlCount() const = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) = 0; + virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) = 0; + + virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) = 0; + virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) = 0; + virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) = 0; + + virtual OUString GetAccessibleObjectName( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const = 0; + virtual OUString GetAccessibleObjectDescription( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const = 0; + + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::vcl::AccessibleBrowseBoxObjType _eType ) const = 0; + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const = 0; + virtual void GrabTableFocus() = 0; + + // OutputDevice + virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, MetricVector& rVector ) = 0; + + // Window + virtual tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const = 0; + virtual void GrabFocus() = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() = 0; + virtual vcl::Window* GetAccessibleParentWindow() const = 0; + virtual vcl::Window* GetWindowInstance() = 0; + + virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) = 0; + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) = 0; + +protected: + ~IAccessibleTableProvider() {} +}; + + +/** interface for an implementation of a table control's Accessible component +*/ +class IAccessibleTabListBox +{ +public: + /** returns the XAccessible object itself + + The reference returned here can be used to control the life time of the + IAccessibleTableImplementation object. + + The returned reference is guaranteed to not be <NULL/>. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getMyself() = 0; + + /** returns the accessible object for the column header bar + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getHeaderBar() = 0; + +protected: + ~IAccessibleTabListBox() {} +}; + +/** interface for an implementation of a browse box's Accessible component +*/ +class IAccessibleBrowseBox +{ +public: + /** returns the XAccessible object itself + + The reference returned here can be used to control the life time of the + IAccessibleTableImplementation object. + + The returned reference is guaranteed to not be <NULL/>. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getMyself() = 0; + + /** disposes the accessible implementation, so that it becomes defunc + */ + virtual void dispose() = 0; + + /** checks whether the accessible implementation, and its context, are still alive + @return <TRUE/>, if the object is not disposed or disposing. + */ + virtual bool isAlive() const = 0; + + /** returns the accessible object for the row or the column header bar + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getHeaderBar( ::vcl::AccessibleBrowseBoxObjType _eObjType ) = 0; + + /** returns the accessible object for the table representation + */ + virtual css::uno::Reference< css::accessibility::XAccessible > + getTable() = 0; + + /** commits the event at all listeners of the column/row header bar + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + virtual void commitHeaderBarEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue, + bool _bColumnHeaderBar + ) = 0; + + /** commits the event at all listeners of the table + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + virtual void commitTableEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue + ) = 0; + + /** Commits an event to all listeners. */ + virtual void commitEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue + ) = 0; + +protected: + ~IAccessibleBrowseBox() {} +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_ACCESSIBLETABLEPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx new file mode 100644 index 000000000..159c61243 --- /dev/null +++ b/include/vcl/alpha.hxx @@ -0,0 +1,82 @@ +/* -*- 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_ALPHA_HXX +#define INCLUDED_VCL_ALPHA_HXX + +#include <sal/config.h> + +#include <utility> + +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> + +class BitmapEx; + +class VCL_DLLPUBLIC AlphaMask : public Bitmap +{ +public: + + AlphaMask(); + explicit AlphaMask( const Bitmap& rBitmap ); + AlphaMask( const AlphaMask& rAlphaMask ); + AlphaMask( AlphaMask&& rAlphaMask ); + explicit AlphaMask( const Size& rSizePixel, const sal_uInt8* pEraseTransparency = nullptr ); + virtual ~AlphaMask() override; + + AlphaMask& operator=( const Bitmap& rBitmap ); + AlphaMask& operator=( const AlphaMask& rAlphaMask ) { return static_cast<AlphaMask&>( Bitmap::operator=( rAlphaMask ) ); } + AlphaMask& operator=( AlphaMask&& rAlphaMask ) noexcept { return static_cast<AlphaMask&>( Bitmap::operator=( std::move(rAlphaMask) ) ); } + bool operator!() const { return Bitmap::operator!(); } + bool operator==( const AlphaMask& rAlphaMask ) const { return Bitmap::operator==(rAlphaMask); } + bool operator!=( const AlphaMask& rAlphaMask ) const { return Bitmap::operator!=(rAlphaMask); } + + void SetPrefMapMode( const MapMode& rMapMode ) { Bitmap::SetPrefMapMode( rMapMode ); } + + void SetPrefSize( const Size& rSize ) { Bitmap::SetPrefSize( rSize ); } + + Bitmap const & GetBitmap() const; + + void Erase( sal_uInt8 cTransparency ); + void Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency ); + void Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency ); + void BlendWith(const Bitmap& rOther); + + BitmapReadAccess* AcquireAlphaReadAccess() { return Bitmap::AcquireReadAccess(); } + BitmapWriteAccess* AcquireAlphaWriteAccess() { return Bitmap::AcquireWriteAccess(); } + + void ReleaseAccess( BitmapReadAccess* pAccess ); + + typedef vcl::ScopedBitmapAccess<BitmapReadAccess, AlphaMask, &AlphaMask::AcquireAlphaReadAccess> ScopedReadAccess; + + using Bitmap::IsEmpty; + +private: + friend class BitmapEx; + friend class ::OutputDevice; + friend bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx& rTarget, SvStream& rIStm, bool bFileHeader, bool bMSOFormat); + + SAL_DLLPRIVATE const Bitmap& ImplGetBitmap() const; + SAL_DLLPRIVATE void ImplSetBitmap( const Bitmap& rBitmap ); + +}; + +#endif // INCLUDED_VCL_ALPHA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/animate/Animation.hxx b/include/vcl/animate/Animation.hxx new file mode 100644 index 000000000..c606fb7a8 --- /dev/null +++ b/include/vcl/animate/Animation.hxx @@ -0,0 +1,117 @@ +/* -*- 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_ANIMATE_ANIMATION_HXX +#define INCLUDED_VCL_ANIMATE_ANIMATION_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/animate/AnimationBitmap.hxx> + +#define ANIMATION_TIMEOUT_ON_CLICK 2147483647L + +class ImplAnimView; + +class VCL_DLLPUBLIC Animation +{ +public: + Animation(); + Animation(const Animation& rAnimation); + ~Animation(); + + Animation& operator=(const Animation& rAnimation); + bool operator==(const Animation& rAnimation) const; + bool operator!=(const Animation& rAnimation) const { return !(*this == rAnimation); } + + void Clear(); + + bool Start(OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz, long nExtraData, + OutputDevice* pFirstFrameOutDev); + + void Stop(OutputDevice* pOutDev = nullptr, long nExtraData = 0); + + void Draw(OutputDevice* pOutDev, const Point& rDestPt) const; + void Draw(OutputDevice* pOutDev, const Point& rDestPt, const Size& rDestSz) const; + + bool IsInAnimation() const { return mbIsInAnimation; } + bool IsTransparent() const; + + const Size& GetDisplaySizePixel() const { return maGlobalSize; } + void SetDisplaySizePixel(const Size& rSize) { maGlobalSize = rSize; } + + const BitmapEx& GetBitmapEx() const { return maBitmapEx; } + void SetBitmapEx(const BitmapEx& rBmpEx) { maBitmapEx = rBmpEx; } + + sal_uInt32 GetLoopCount() const { return mnLoopCount; } + void SetLoopCount(const sal_uInt32 nLoopCount); + void ResetLoopCount(); + + void SetNotifyHdl(const Link<Animation*, void>& rLink) { maNotifyLink = rLink; } + const Link<Animation*, void>& GetNotifyHdl() const { return maNotifyLink; } + + std::vector<std::unique_ptr<AnimationBitmap>>& GetAnimationFrames() { return maList; } + size_t Count() const { return maList.size(); } + bool Insert(const AnimationBitmap& rAnimationBitmap); + const AnimationBitmap& Get(sal_uInt16 nAnimation) const; + void Replace(const AnimationBitmap& rNewAnimationBmp, sal_uInt16 nAnimation); + + sal_uLong GetSizeBytes() const; + BitmapChecksum GetChecksum() const; + +public: + void Convert(BmpConversion eConversion); + bool ReduceColors(sal_uInt16 nNewColorCount); + + bool Invert(); + void Mirror(BmpMirrorFlags nMirrorFlags); + void Adjust(short nLuminancePercent, short nContrastPercent, short nChannelRPercent, + short nChannelGPercent, short nChannelBPercent, double fGamma = 1.0, + bool bInvert = false); + + friend SvStream& ReadAnimation(SvStream& rIStream, Animation& rAnimation); + friend SvStream& WriteAnimation(SvStream& rOStream, const Animation& rAnimation); + +public: + SAL_DLLPRIVATE static void ImplIncAnimCount() { mnAnimCount++; } + SAL_DLLPRIVATE static void ImplDecAnimCount() { mnAnimCount--; } + SAL_DLLPRIVATE sal_uLong ImplGetCurPos() const { return mnPos; } + +private: + SAL_DLLPRIVATE static sal_uLong mnAnimCount; + + std::vector<std::unique_ptr<AnimationBitmap>> maList; + std::vector<std::unique_ptr<ImplAnimView>> maViewList; + + Link<Animation*, void> maNotifyLink; + BitmapEx maBitmapEx; + Timer maTimer; + Size maGlobalSize; + sal_uInt32 mnLoopCount; + sal_uInt32 mnLoops; + size_t mnPos; + bool mbIsInAnimation; + bool mbLoopTerminated; + + SAL_DLLPRIVATE void ImplRestartTimer(sal_uLong nTimeout); + DECL_DLLPRIVATE_LINK(ImplTimeoutHdl, Timer*, void); +}; + +#endif // INCLUDED_VCL_ANIMATE_ANIMATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/animate/AnimationBitmap.hxx b/include/vcl/animate/AnimationBitmap.hxx new file mode 100644 index 000000000..5b438f8c4 --- /dev/null +++ b/include/vcl/animate/AnimationBitmap.hxx @@ -0,0 +1,79 @@ +/* -*- 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_ANIMATE_ANIMATIONBITMAP_HXX +#define INCLUDED_VCL_ANIMATE_ANIMATIONBITMAP_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> + +enum class Disposal +{ + Not, + Back, + Previous +}; + +struct AnimationBitmap +{ + BitmapEx maBitmapEx; + Point maPositionPixel; + Size maSizePixel; + long mnWait; + Disposal meDisposal; + bool mbUserInput; + + AnimationBitmap() + : mnWait(0) + , meDisposal(Disposal::Not) + , mbUserInput(false) + { + } + + AnimationBitmap(const BitmapEx& rBitmapEx, const Point& rPositionPixel, const Size& rSizePixel, + long nWait = 0, Disposal eDisposal = Disposal::Not) + : maBitmapEx(rBitmapEx) + , maPositionPixel(rPositionPixel) + , maSizePixel(rSizePixel) + , mnWait(nWait) + , meDisposal(eDisposal) + , mbUserInput(false) + { + } + + bool operator==(const AnimationBitmap& rAnimationBitmap) const + { + return (rAnimationBitmap.maBitmapEx == maBitmapEx + && rAnimationBitmap.maPositionPixel == maPositionPixel + && rAnimationBitmap.maSizePixel == maSizePixel && rAnimationBitmap.mnWait == mnWait + && rAnimationBitmap.meDisposal == meDisposal + && rAnimationBitmap.mbUserInput == mbUserInput); + } + + bool operator!=(const AnimationBitmap& rAnimationBitmap) const + { + return !(*this == rAnimationBitmap); + } + + BitmapChecksum GetChecksum() const; +}; + +#endif // INCLUDED_VCL_ANIMATE_ANIMATIONBITMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx new file mode 100644 index 000000000..9ed602942 --- /dev/null +++ b/include/vcl/bitmap.hxx @@ -0,0 +1,589 @@ +/* -*- 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_BITMAP_HXX +#define INCLUDED_VCL_BITMAP_HXX + +#include <tools/solar.h> +#include <vcl/checksum.hxx> +#include <vcl/dllapi.h> +#include <vcl/mapmod.hxx> +#include <vcl/region.hxx> +#include <vcl/scopedbitmapaccess.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <memory> + +class Color; + +template <typename Arg, typename Ret> class Link; + +enum class BmpMirrorFlags +{ + NONE = 0x00, + Horizontal = 0x01, + Vertical = 0x02, +}; + +namespace o3tl +{ + template<> struct typed_flags<BmpMirrorFlags> : is_typed_flags<BmpMirrorFlags, 0x03> {}; +} + +enum class BmpScaleFlag +{ +// Try to preferably use these. + Default, + Fast, + BestQuality, +// Specific algorithms, use only if you really need to (mainly used for tests) + NearestNeighbor, + Interpolate, // fast, integer bilinear + Lanczos, + BiCubic, + BiLinear, + Super // bilinear interpolation when supersampling and averaging when subsampling under certain scale +}; + +#define BMP_COL_TRANS Color( 252, 3, 251 ) + +enum class BmpConversion +{ + NNONE, + N1BitThreshold, + N4BitGreys, + N4BitColors, + N8BitGreys, + N8BitColors, + N24Bit, + N32Bit, + N8BitTrans, + N8BitNoConversion // make 8bit without color conversion (e.g. take the red channel) +}; + +enum class BmpCombine +{ + Or, And +}; + +class BitmapInfoAccess; +class BitmapReadAccess; +class BitmapWriteAccess; +class BitmapPalette; +class GDIMetaFile; +class AlphaMask; +class OutputDevice; +class SalBitmap; + +struct BitmapSystemData +{ + #if defined(_WIN32) + void* pDIB; // device independent byte buffer + #elif defined( MACOSX ) || defined( IOS ) + // Nothing needed, apparently + #else + void* aPixmap; + #endif + int mnWidth; + int mnHeight; +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC Bitmap +{ +public: + + Bitmap(); + Bitmap( const Bitmap& rBitmap ); + Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = nullptr ); + explicit Bitmap( std::shared_ptr<SalBitmap> const & xSalBitmap ); + virtual ~Bitmap(); + + Bitmap& operator=( const Bitmap& rBitmap ); + Bitmap& operator=( Bitmap&& rBitmap ) noexcept; + inline bool operator!() const; + bool operator==( const Bitmap& rBitmap ) const; + bool operator!=( const Bitmap& rBitmap ) const { return !operator==(rBitmap); } + + inline bool IsEmpty() const; + void SetEmpty(); + + inline const MapMode& GetPrefMapMode() const; + inline void SetPrefMapMode( const MapMode& rMapMode ); + + inline const Size& GetPrefSize() const; + inline void SetPrefSize( const Size& rSize ); + + Size GetSizePixel() const; + + sal_uInt16 GetBitCount() const; + inline sal_Int64 GetColorCount() const; + inline sal_uLong GetSizeBytes() const; + bool HasGreyPalette8Bit() const; + bool HasGreyPaletteAny() const; + /** get system dependent bitmap data + + @param rData + The system dependent BitmapSystemData structure to be filled + + @return true if the bitmap has a valid system object (e.g. not empty) + */ + bool GetSystemData( BitmapSystemData& rData ) const; + + BitmapChecksum GetChecksum() const; + + Bitmap CreateDisplayBitmap( OutputDevice* pDisplay ) const; + + static const BitmapPalette& + GetGreyPalette( int nEntries ); + +public: + + /** Convert bitmap format + + @param eConversion + The format this bitmap should be converted to. + + @return true the conversion was completed successfully. + */ + bool Convert( BmpConversion eConversion ); + + /** Apply a Floyd dither algorithm to the bitmap + + This method dithers the bitmap inplace, i.e. a true color + bitmap is converted to a paletted bitmap, reducing the color + deviation by error diffusion. + + */ + bool Dither(); + + /** Crop the bitmap + + @param rRectPixel + A rectangle specifying the crop amounts on all four sides of + the bitmap. If the upper left corner of the bitmap is assigned + (0,0), then this method cuts out the given rectangle from the + bitmap. Note that the rectangle is clipped to the bitmap's + dimension, i.e. negative left,top rectangle coordinates or + exceeding width or height is ignored. + + @return true cropping was performed successfully. If + nothing had to be cropped, because e.g. the crop rectangle + included the bitmap, false is returned, too! + */ + bool Crop( const tools::Rectangle& rRectPixel ); + + /** Expand the bitmap by pixel padding + + @param nDX + Number of pixel to pad at the right border of the bitmap + + @param nDY + Number of scanlines to pad at the bottom border of the bitmap + + @param pInitColor + Color to use for padded pixel + + @return true, if padding was performed successfully. false is + not only returned when the operation failed, but also if + nothing had to be done, e.g. because nDX and nDY were zero. + */ + bool Expand( + sal_uLong nDX, sal_uLong nDY, + const Color* pInitColor = nullptr ); + + /** Copy a rectangular area from another bitmap + + @param rRectDst + Destination rectangle in this bitmap. This is clipped to the + bitmap dimensions. + + @param rRectSrc + Source rectangle in pBmpSrc. This is clipped to the source + bitmap dimensions. Note further that no scaling takes place + during this copy operation, i.e. only the minimum of source + and destination rectangle's width and height are used. + + @param pBmpSrc + The source bitmap to copy from. If this argument is NULL, or + equal to the object this method is called on, copying takes + place within the same bitmap. + + @return true, if the operation completed successfully. false + is not only returned when the operation failed, but also if + nothing had to be done, e.g. because one of the rectangles are + empty. + */ + bool CopyPixel( + const tools::Rectangle& rRectDst, + const tools::Rectangle& rRectSrc, + const Bitmap* pBmpSrc = nullptr ); + + bool CopyPixel_AlphaOptimized( + const tools::Rectangle& rRectDst, + const tools::Rectangle& rRectSrc, + const Bitmap* pBmpSrc ); + + /** Perform boolean operations with another bitmap + + @param rMask + The mask bitmap in the selected combine operation + + @param eCombine + The combine operation to perform on the bitmap + + @return true, if the operation was completed successfully. + */ + bool CombineSimple( + const Bitmap& rMask, + BmpCombine eCombine ); + + /** Alpha-blend the given bitmap against a specified uniform + background color. + + @attention This method might convert paletted bitmaps to + truecolor, to be able to represent every necessary color. Note + that during alpha blending, lots of colors not originally + included in the bitmap can be generated. + + @param rAlpha + Alpha mask to blend with + + @param rBackgroundColor + Background color to use for every pixel during alpha blending + + @return true, if blending was successful, false otherwise + */ + bool Blend( + const AlphaMask& rAlpha, + const Color& rBackgroundColor ); + + /** Fill the entire bitmap with the given color + + @param rFillColor + Color value to use for filling + + @return true, if the operation was completed successfully. + */ + bool Erase( const Color& rFillColor ); + + /** Perform the Invert operation on every pixel + + @return true, if the operation was completed successfully. + */ + bool Invert(); + + /** Mirror the bitmap + + @param nMirrorFlags + About which axis (horizontal, vertical, or both) to mirror + + @return true, if the operation was completed successfully. + */ + bool Mirror( BmpMirrorFlags nMirrorFlags ); + + /** Scale the bitmap + + @param rNewSize + The resulting size of the scaled bitmap + + @param nScaleFlag + The algorithm to be used for scaling + + @return true, if the operation was completed successfully. + */ + bool Scale( const Size& rNewSize, BmpScaleFlag nScaleFlag = BmpScaleFlag::Default ); + + /** Scale the bitmap + + @param rScaleX + The scale factor in x direction. + + @param rScaleY + The scale factor in y direction. + + @param nScaleFlag + Method of scaling - it is recommended that either BmpScaleFlag::Default or BmpScaleFlag::BestQuality be used. + + @return true, if the operation was completed successfully. + */ + bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag = BmpScaleFlag::Default ); + + /** + Returns true if bitmap scaling is considered to be fast. + + Currently this returns true if OpenGL is used for scaling, otherwise false (CPU scaling is slower). + + @since 4.5 + */ + static bool HasFastScale(); + + // Adapt the BitCount of rNew to BitCount of total, including grey or color palette + // Can be used to create alpha/mask bitmaps after their processing in 24bit + void AdaptBitCount(Bitmap& rNew) const; + + /** Rotate bitmap by the specified angle + + @param nAngle10 + The rotation angle in tenth of a degree. The bitmap is always rotated around its center. + + @param rFillColor + The color to use for filling blank areas. During rotation, the + bitmap is enlarged such that the whole rotation result fits + in. The empty spaces around that rotated original bitmap are + then filled with this color. + + @return true, if the operation was completed successfully. + */ + bool Rotate( long nAngle10, const Color& rFillColor ); + + /** Create on-off mask from bitmap + + This method creates a bitmask from the bitmap, where every + pixel that equals rTransColor is set transparent, the rest + opaque. + + @param rTransColor + Color value where the bitmask should be transparent + + @param nTol + Tolerance value. Specifies the maximal difference between + rTransColor and the individual pixel values, such that the + corresponding pixel is still regarded as transparent. + + @return the resulting bitmask. + */ + Bitmap CreateMask( const Color& rTransColor, sal_uInt8 nTol = 0 ) const; + + /** Create region of similar colors in a given rectangle + + @param rColor + All pixel which have this color are included in the calculated region + + @param rRect + The rectangle within which matching pixel are looked for. This + rectangle is always clipped to the bitmap dimensions. + + @return the generated region. + */ + vcl::Region CreateRegion( const Color& rColor, const tools::Rectangle& rRect ) const; + + /** Replace all pixel where the given mask is on with the specified color + + @param rMask + Mask specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @return true, if the operation was completed successfully. + */ + bool Replace( const Bitmap& rMask, const Color& rReplaceColor ); + + /** Merge bitmap with given background color according to specified alpha mask + + @param rAlpha + Alpha mask specifying the amount of background color to merge in + + @param rMergeColor + Background color to be used for merging + + @return true, if the operation was completed successfully. + */ + bool Replace( const AlphaMask& rAlpha, const Color& rMergeColor ); + + /** Replace all pixel having the search color with the specified color + + @param rSearchColor + Color specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @param nTol + Tolerance value. Specifies the maximal difference between + rSearchColor and the individual pixel values, such that the + corresponding pixel is still regarded a match. + + @return true, if the operation was completed successfully. + */ + bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol = 0 ); + + /** Replace all pixel having one the search colors with the corresponding replace color + + @param pSearchColors + Array of colors specifying which pixel should be replaced + + @param rReplaceColors + Array of colors to be placed in all changed pixel + + @param nColorCount + Size of the aforementioned color arrays + + @param pTols + Tolerance value. Specifies the maximal difference between + pSearchColor colors and the individual pixel values, such that + the corresponding pixel is still regarded a match. + + @return true, if the operation was completed successfully. + */ + bool Replace( + const Color* pSearchColors, + const Color* rReplaceColors, + sal_uLong nColorCount, + sal_uInt8 const * pTols ); + + /** Convert the bitmap to a meta file + + This works by putting continuous areas of the same color into + polygons painted in this color, by tracing the area's bounding + line. + + @param rMtf + The resulting meta file + + @param cReduce + If non-null, minimal size of bound rects for individual polygons. Smaller ones are ignored. + + @param pProgress + A callback for showing the progress of the vectorization + */ + void Vectorize( + GDIMetaFile& rMtf, + sal_uInt8 cReduce, + const Link<long,void>* pProgress ); + + /** Change various global color characteristics + + @param nLuminancePercent + Percent of luminance change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nContrastPercent + Percent of contrast change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelRPercent + Percent of red channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelGPercent + Percent of green channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelBPercent + Percent of blue channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param fGamma + Exponent of the gamma function applied to the bitmap. The + value 1.0 results in no change, the valid range is + (0.0,10.0]. Values outside this range are regarded as 1.0. + + @param bInvert + If true, invert the channel values with the logical 'not' operator + + @param msoBrightness + Use the same formula for brightness as used by MSOffice. + + @return true, if the operation was completed successfully. + */ + bool Adjust( + short nLuminancePercent, + short nContrastPercent = 0, + short nChannelRPercent = 0, + short nChannelGPercent = 0, + short nChannelBPercent = 0, + double fGamma = 1.0, + bool bInvert = false, + bool msoBrightness = false ); + +public: + /** ReassignWithSize and recalculate bitmap. + + ReassignWithSizes the bitmap, and recalculates the bitmap size based on the new bitmap. + + @param rBitmap Bitmap to reassign and use for size calculation + */ + SAL_DLLPRIVATE void ReassignWithSize(const Bitmap& rBitmap); + + SAL_DLLPRIVATE void ImplMakeUnique(); + const std::shared_ptr<SalBitmap>& ImplGetSalBitmap() const { return mxSalBmp; } + SAL_DLLPRIVATE void ImplSetSalBitmap( const std::shared_ptr<SalBitmap>& xImpBmp ); + + SAL_DLLPRIVATE bool ImplMakeGreyscales( sal_uInt16 nGreyscales ); + +public: + + BitmapInfoAccess* AcquireInfoAccess(); + BitmapReadAccess* AcquireReadAccess(); + BitmapWriteAccess* AcquireWriteAccess(); + static void ReleaseAccess( BitmapInfoAccess* pAccess ); + + typedef vcl::ScopedBitmapAccess<BitmapReadAccess, Bitmap, &Bitmap::AcquireReadAccess> ScopedReadAccess; + typedef vcl::ScopedBitmapAccess<BitmapInfoAccess, Bitmap, &Bitmap::AcquireInfoAccess> ScopedInfoAccess; + +private: + SAL_DLLPRIVATE bool ImplConvertUp(sal_uInt16 nBitCount, Color const* pExtColor = nullptr); + SAL_DLLPRIVATE bool ImplConvertDown(sal_uInt16 nBitCount, Color const* pExtColor = nullptr); + +private: + std::shared_ptr<SalBitmap> mxSalBmp; + MapMode maPrefMapMode; + Size maPrefSize; + +}; + +inline bool Bitmap::operator!() const +{ + return( mxSalBmp == nullptr ); +} + +inline bool Bitmap::IsEmpty() const +{ + return( mxSalBmp == nullptr ); +} + +inline const MapMode& Bitmap::GetPrefMapMode() const +{ + return maPrefMapMode; +} + +inline void Bitmap::SetPrefMapMode( const MapMode& rMapMode ) +{ + maPrefMapMode = rMapMode; +} + +inline const Size& Bitmap::GetPrefSize() const +{ + return maPrefSize; +} + +inline void Bitmap::SetPrefSize( const Size& rSize ) +{ + maPrefSize = rSize; +} + +inline sal_Int64 Bitmap::GetColorCount() const +{ + return sal_Int64(1) << sal_Int64(GetBitCount()); +} + +inline sal_uLong Bitmap::GetSizeBytes() const +{ + const Size aSizePix( GetSizePixel() ); + return( ( static_cast<sal_uLong>(aSizePix.Width()) * aSizePix.Height() * GetBitCount() ) >> 3 ); +} + +#endif // INCLUDED_VCL_BITMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmapaccess.hxx b/include/vcl/bitmapaccess.hxx new file mode 100644 index 000000000..da29fee9a --- /dev/null +++ b/include/vcl/bitmapaccess.hxx @@ -0,0 +1,285 @@ +/* -*- 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_BMPACC_HXX +#define INCLUDED_VCL_BMPACC_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmap.hxx> +#include <vcl/Scanline.hxx> +#include <vcl/BitmapBuffer.hxx> +#include <vcl/BitmapColor.hxx> +#include <vcl/BitmapAccessMode.hxx> + +typedef BitmapColor (*FncGetPixel)(ConstScanline pScanline, long nX, const ColorMask& rMask); +typedef void (*FncSetPixel)(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + +class VCL_DLLPUBLIC BitmapInfoAccess +{ + friend class BitmapReadAccess; + +public: + BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info); + virtual ~BitmapInfoAccess(); + + bool operator!() const + { + return mpBuffer == nullptr; + } + + long Width() const + { + return mpBuffer ? mpBuffer->mnWidth : 0L; + } + + long Height() const + { + return mpBuffer ? mpBuffer->mnHeight : 0L; + } + + bool IsTopDown() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown); + } + + bool IsBottomUp() const + { + return !IsTopDown(); + } + + ScanlineFormat GetScanlineFormat() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : ScanlineFormat::NONE; + } + + sal_uInt32 GetScanlineSize() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer ? mpBuffer->mnScanlineSize : 0; + } + + sal_uInt16 GetBitCount() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer ? mpBuffer->mnBitCount : 0; + } + + BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor) + { + if (HasPalette()) + return BitmapColor(static_cast<sal_uInt8>(GetBestPaletteIndex(rBitmapColor))); + else + return rBitmapColor; + } + + bool HasPalette() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer && !!mpBuffer->maPalette; + } + + const BitmapPalette& GetPalette() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer->maPalette; + } + + sal_uInt16 GetPaletteEntryCount() const + { + assert(HasPalette() && "Bitmap has no palette!"); + + return HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0; + } + + const BitmapColor& GetPaletteColor( sal_uInt16 nColor ) const + { + assert(mpBuffer && "Access is not valid!"); + assert(HasPalette() && "Bitmap has no palette!"); + + return mpBuffer->maPalette[nColor]; + } + + const BitmapColor& GetBestPaletteColor(const BitmapColor& rBitmapColor) const + { + return GetPaletteColor(GetBestPaletteIndex(rBitmapColor)); + } + + sal_uInt16 GetBestPaletteIndex(const BitmapColor& rBitmapColor) const; + + ColorMask& GetColorMask() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer->maColorMask; + } + +private: + BitmapInfoAccess(const BitmapInfoAccess&) = delete; + BitmapInfoAccess& operator=(const BitmapInfoAccess&) = delete; + +protected: + Bitmap maBitmap; + BitmapBuffer* mpBuffer; + ColorMask maColorMask; + BitmapAccessMode mnAccessMode; +}; + + +class VCL_DLLPUBLIC BitmapReadAccess : public BitmapInfoAccess +{ + friend class BitmapWriteAccess; + +public: + BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Read); + virtual ~BitmapReadAccess() override; + + Scanline GetBuffer() const + { + assert(mpBuffer && "Access is not valid!"); + + return mpBuffer ? mpBuffer->mpBits : nullptr; + } + + Scanline GetScanline(long nY) const + { + assert(mpBuffer && "Access is not valid!"); + assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); + + if (mpBuffer->mnFormat & ScanlineFormat::TopDown) + { + return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize); + } + return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize); + } + + BitmapColor GetPixelFromData(const sal_uInt8* pData, long nX) const + { + assert(pData && "Access is not valid!"); + + return mFncGetPixel( pData, nX, maColorMask ); + } + + sal_uInt8 GetIndexFromData(const sal_uInt8* pData, long nX) const + { + return GetPixelFromData( pData, nX ).GetIndex(); + } + + void SetPixelOnData(sal_uInt8* pData, long nX, const BitmapColor& rBitmapColor) + { + assert(pData && "Access is not valid!"); + + mFncSetPixel(pData, nX, rBitmapColor, maColorMask); + } + + BitmapColor GetPixel(long nY, long nX) const + { + assert(mpBuffer && "Access is not valid!"); + assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!"); + assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!"); + + return mFncGetPixel(GetScanline(nY), nX, maColorMask ); + } + + BitmapColor GetColor(long nY, long nX) const + { + if (HasPalette()) + return mpBuffer->maPalette[GetPixelIndex(nY, nX)]; + else + return GetPixel(nY, nX); + } + + sal_uInt8 GetPixelIndex(long nY, long nX) const + { + return GetPixel(nY, nX).GetIndex(); + } + + /** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */ + BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; + + /** Get the color at coordinates fY, fX; if outside, return rFallback. Automatically does the correct + inside/outside checks, e.g. static_cast< sal_uInt32 >(-0.25) *is* 0, not -1 and has to be outside */ + BitmapColor GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const; + +private: + BitmapReadAccess(const BitmapReadAccess&) = delete; + BitmapReadAccess& operator=(const BitmapReadAccess&) = delete; + +protected: + FncGetPixel mFncGetPixel; + FncSetPixel mFncSetPixel; + + SAL_DLLPRIVATE bool ImplSetAccessPointers( ScanlineFormat nFormat ); + +public: + + SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const + { + return mpBuffer; + } + + static BitmapColor GetPixelForN1BitMsbPal(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN1BitLsbPal(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN4BitMsnPal(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN4BitLsnPal(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN8BitPal(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN8BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, long nX, const ColorMask& rMask); + static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, long nX, const ColorMask& rMask); + + static void SetPixelForN1BitMsbPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN1BitLsbPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN4BitMsnPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN4BitLsnPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN8BitPal(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN8BitTcMask(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN24BitTcBgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN24BitTcRgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcAbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcXbgr(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcArgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcXrgb(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcBgra(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcBgrx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcRgba(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcRgbx(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + static void SetPixelForN32BitTcMask(Scanline pScanline, long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask); + +}; + + +#endif // INCLUDED_VCL_BMPACC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx new file mode 100644 index 000000000..4dac473bb --- /dev/null +++ b/include/vcl/bitmapex.hxx @@ -0,0 +1,526 @@ +/* -*- 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_BITMAPEX_HXX +#define INCLUDED_VCL_BITMAPEX_HXX + +#include <vcl/dllapi.h> +#include <vcl/alpha.hxx> +#include <vcl/Scanline.hxx> +#include <tools/color.hxx> + +#include <sal/types.h> + +namespace com::sun::star::rendering { + class XBitmapCanvas; +} +namespace com::sun::star::uno { template <class interface_type> class Reference; } +namespace basegfx { class BColorModifierStack; } + +enum class TransparentType +{ + NONE, + Color, + Bitmap +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx +{ +public: + + BitmapEx(); + explicit BitmapEx( const OUString& rIconName ); + BitmapEx( const BitmapEx& rBitmapEx ); + BitmapEx( const BitmapEx& rBitmapEx, Point aSrc, Size aSize ); + BitmapEx( Size aSize, sal_uInt16 nBitCount ); + explicit BitmapEx( const Bitmap& rBmp ); + BitmapEx( const Bitmap& rBmp, const Bitmap& rMask ); + BitmapEx( const Bitmap& rBmp, const AlphaMask& rAlphaMask ); + BitmapEx( const Bitmap& rBmp, const Color& rTransparentColor ); + + BitmapEx& operator=( const BitmapEx& rBitmapEx ); + BitmapEx& operator=( const Bitmap& rBitmap ) { return operator=(BitmapEx(rBitmap)); } + bool operator==( const BitmapEx& rBitmapEx ) const; + bool operator!=( const BitmapEx& rBitmapEx ) const { return !(*this==rBitmapEx); } + bool operator!() const { return !maBitmap; } + + bool IsEmpty() const; + void SetEmpty(); + void Clear(); + + void Draw( OutputDevice* pOutDev, + const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, + const Point& rDestPt, const Size& rDestSize ) const; + + bool IsTransparent() const; + TransparentType GetTransparentType() const { return meTransparent; } + + Bitmap GetBitmap( Color aTransparentReplaceColor ) const; + /// Gives direct access to the contained bitmap. + const Bitmap& GetBitmap() const; + Bitmap GetMask() const; + + bool IsAlpha() const; + AlphaMask GetAlpha() const; + + const Size& GetSizePixel() const { return maBitmapSize; } + void SetSizePixel(const Size& rNewSize); + + const Size& GetPrefSize() const { return maBitmap.GetPrefSize(); } + void SetPrefSize( const Size& rPrefSize ) { maBitmap.SetPrefSize( rPrefSize ); } + + const MapMode& GetPrefMapMode() const { return maBitmap.GetPrefMapMode(); } + void SetPrefMapMode( const MapMode& rPrefMapMode ) { maBitmap.SetPrefMapMode( rPrefMapMode ); } + + const Color& GetTransparentColor() const { return maTransparentColor; } + + sal_uInt16 GetBitCount() const { return maBitmap.GetBitCount(); } + sal_uLong GetSizeBytes() const; + BitmapChecksum GetChecksum() const; + + /** Convert bitmap format + + @param eConversion + The format this bitmap should be converted to. + + @return true, if the conversion was completed successfully. + */ + bool Convert( BmpConversion eConversion ); + + /** Crop the bitmap + + @param rRectPixel + A rectangle specifying the crop amounts on all four sides of + the bitmap. If the upper left corner of the bitmap is assigned + (0,0), then this method cuts out the given rectangle from the + bitmap. Note that the rectangle is clipped to the bitmap's + dimension, i.e. negative left,top rectangle coordinates or + exceeding width or height is ignored. + + @return true, if cropping was performed successfully. If + nothing had to be cropped, because e.g. the crop rectangle + included the bitmap, false is returned, too! + */ + bool Crop( const tools::Rectangle& rRectPixel ); + + /** Expand the bitmap by pixel padding + + @param nDX + Number of pixel to pad at the right border of the bitmap + + @param nDY + Number of scanlines to pad at the bottom border of the bitmap + + @param bExpandTransparent + Whether to expand the transparency color or not. + */ + void Expand( + sal_uLong nDX, sal_uLong nDY, + bool bExpandTransparent = false ); + + /** Copy a rectangular area from another bitmap + + @param rRectDst + Destination rectangle in this bitmap. This is clipped to the + bitmap dimensions. + + @param rRectSrc + Source rectangle in pBmpSrc. This is clipped to the source + bitmap dimensions. Note further that no scaling takes place + during this copy operation, i.e. only the minimum of source + and destination rectangle's width and height are used. + + @param pBmpExSrc + The source bitmap to copy from. If this argument is NULL, or + equal to the object this method is called on, copying takes + place within the same bitmap. + + @return true, if the operation completed successfully. false + is not only returned when the operation failed, but also if + nothing had to be done, e.g. because one of the rectangles are + empty. + */ + bool CopyPixel( + const tools::Rectangle& rRectDst, + const tools::Rectangle& rRectSrc, + const BitmapEx* pBmpExSrc ); + + /** Fill the entire bitmap with the given color + + @param rFillColor + Color value to use for filling. Set the transparency part of + the color to fill the mask. + + @return true, if the operation was completed successfully. + */ + bool Erase( const Color& rFillColor ); + + /** Perform the Invert operation on every pixel + + @return true, if the operation was completed successfully. + */ + bool Invert(); + + /** Mirror the bitmap + + @param nMirrorFlags + About which axis (horizontal, vertical, or both) to mirror + + @return true, if the operation was completed successfully. + */ + bool Mirror( BmpMirrorFlags nMirrorFlags ); + + /** Scale the bitmap + + @param rNewSize + The resulting size of the scaled bitmap + + @param nScaleFlag + The algorithm to be used for scaling + + @return true, if the operation was completed successfully. + */ + bool Scale( + const Size& rNewSize, + BmpScaleFlag nScaleFlag = BmpScaleFlag::Default ); + + /** Scale the bitmap + + @param rScaleX + The scale factor in x direction. + + @param rScaleY + The scale factor in y direction. + + @param nScaleFlag + The algorithm to be used for scaling + + @return true, if the operation was completed successfully. + */ + bool Scale( + const double& rScaleX, + const double& rScaleY, + BmpScaleFlag nScaleFlag = BmpScaleFlag::Default ); + + /** Rotate bitmap by the specified angle + + @param nAngle10 + The rotation angle in tenth of a degree. The bitmap is always rotated around its center. + + @param rFillColor + The color to use for filling blank areas. During rotation, the + bitmap is enlarged such that the whole rotation result fits + in. The empty spaces around that rotated original bitmap are + then filled with this color. + + @return true, if the operation was completed successfully. + */ + bool Rotate( + long nAngle10, + const Color& rFillColor ); + + /** Replace all pixel having the search color with the specified color + + @param rSearchColor + Color specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + */ + void Replace( + const Color& rSearchColor, + const Color& rReplaceColor ); + + /** Replace all pixel having the search color with the specified color + + @param rSearchColor + Color specifying which pixel should be replaced + + @param rReplaceColor + Color to be placed in all changed pixel + + @param nTolerance + Tolerance value. Specifies the maximal difference between + rSearchColor and the individual pixel values, such that the + corresponding pixel is still regarded a match. + */ + void Replace( + const Color& rSearchColor, + const Color& rReplaceColor, + sal_uInt8 nTolerance ); + + /** Replace all pixel having one the search colors with the corresponding replace color + + @param pSearchColors + Array of colors specifying which pixel should be replaced + + @param pReplaceColors + Array of colors to be placed in all changed pixel + + @param nColorCount + Size of the aforementioned color arrays + + @param pTols + Tolerance value. Specifies the maximal difference between + pSearchColor colors and the individual pixel values, such that + the corresponding pixel is still regarded a match. + */ + void Replace( + const Color* pSearchColors, + const Color* pReplaceColors, + sal_uLong nColorCount ); + + /** Replace all pixel having one the search colors with the corresponding replace color + + @param pSearchColors + Array of colors specifying which pixel should be replaced + + @param rReplaceColors + Array of colors to be placed in all changed pixel + + @param nColorCount + Size of the aforementioned color arrays + + @param pTols + Tolerance value. Specifies the maximal difference between + pSearchColor colors and the individual pixel values, such that + the corresponding pixel is still regarded a match. + + @return true, if the operation was completed successfully. + */ + void Replace( + const Color* pSearchColors, + const Color* pReplaceColors, + sal_uLong nColorCount, + sal_uInt8 const * pTols ); + + /** Replace transparency with given color. + */ + void ReplaceTransparency( const Color& rColor ); + + /** Get contours in image */ + tools::Polygon GetContour( bool bContourEdgeDetect, const tools::Rectangle* pWorkRect ); + + /** Change various global color characteristics + + @param nLuminancePercent + Percent of luminance change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nContrastPercent + Percent of contrast change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelRPercent + Percent of red channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelGPercent + Percent of green channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param nChannelBPercent + Percent of blue channel change, valid range [-100,100]. Values outside this range are clipped to the valid range. + + @param fGamma + Exponent of the gamma function applied to the bitmap. The + value 1.0 results in no change, the valid range is + (0.0,10.0]. Values outside this range are regarded as 1.0. + + @param bInvert + If true, invert the channel values with the logical 'not' operator + + @param msoBrightness + Use the same formula for brightness as used by MSOffice. + + @return true, if the operation was completed successfully. + */ + bool Adjust( + short nLuminancePercent, + short nContrastPercent, + short nChannelRPercent, + short nChannelGPercent, + short nChannelBPercent, + double fGamma = 1.0, + bool bInvert = false, + bool msoBrightness = false ); + + /** Get transparency at given position + + @param nX + integer X-Position in Bitmap + + @param nY + integer Y-Position in Bitmap + + @return transparency value in the range of [0 .. 255] where + 0 is not transparent, 255 is fully transparent + */ + sal_uInt8 GetTransparency( + sal_Int32 nX, + sal_Int32 nY) const; + + /** Get pixel color (including alpha) at given position + + @param nX + integer X-Position in Bitmap + + @param nY + integer Y-Position in Bitmap + */ + ::Color GetPixelColor( + sal_Int32 nX, + sal_Int32 nY) const; + + /** Create transformed Bitmap + + @param fWidth + The target width in pixels + + @param fHeight + The target height in pixels + + @param rTransformation + The back transformation for each pixel in (0 .. fWidth),(0 .. fHeight) to + local pixel coordinates + */ + [[nodiscard]] + BitmapEx TransformBitmapEx( + double fWidth, + double fHeight, + const basegfx::B2DHomMatrix& rTransformation) const; + + /** Create transformed Bitmap + + @param rTransformation + The transformation from unit coordinates to the unit range + + @param rVisibleRange + The relative visible range in unit coordinates, relative to (0,0,1,1) which + defines the whole target area + + @param fMaximumArea + A limitation for the maximum size of pixels to use for the result + + The target size of the result bitmap is defined by transforming the given + rTargetRange with the given rTransformation; the area of the result is + linearly scaled to not exceed the given fMaximumArea + + @return The transformed bitmap + */ + [[nodiscard]] + BitmapEx getTransformed( + const basegfx::B2DHomMatrix& rTransformation, + const basegfx::B2DRange& rVisibleRange, + double fMaximumArea) const; + + /** Create ColorStack-modified version of this BitmapEx + + @param rBColorModifierStack + A ColrModifierStack which defines how each pixel has to be modified + */ + [[nodiscard]] + BitmapEx ModifyBitmapEx( const basegfx::BColorModifierStack& rBColorModifierStack) const; + + [[nodiscard]] + static BitmapEx AutoScaleBitmap( BitmapEx const & aBitmap, const long aStandardSize ); + + /// populate from a canvas implementation + bool Create( + const css::uno::Reference< css::rendering::XBitmapCanvas > &xBitmapCanvas, + const Size &rSize ); + + void setAlphaFrom( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ); + + void AdjustTransparency( sal_uInt8 cTrans ); + + void CombineMaskOr(Color maskColor, sal_uInt8 nTol); + + /** + * Retrieves the color model data we need for the XImageConsumer stuff. + */ + void GetColorModel(css::uno::Sequence< sal_Int32 >& rRGBPalette, + sal_uInt32& rnRedMask, sal_uInt32& rnGreenMask, sal_uInt32& rnBlueMask, sal_uInt32& rnAlphaMask, sal_uInt32& rnTransparencyIndex, + sal_uInt32& rnWidth, sal_uInt32& rnHeight, sal_uInt8& rnBitCount); + + SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetBitmapSalBitmap() const { return maBitmap.ImplGetSalBitmap(); } + SAL_DLLPRIVATE std::shared_ptr<SalBitmap> const & ImplGetMaskSalBitmap() const { return maMask.ImplGetSalBitmap(); } + + +private: + friend class ImpGraphic; + friend class OutputDevice; + friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm); + friend bool VCL_DLLPUBLIC ReadRawDIB(BitmapEx& rTarget, const unsigned char* pBuf, + const ScanlineFormat nFormat, + const int nHeight, + const int nStride); + + void loadFromIconTheme( const OUString& rIconName ); + + Bitmap maBitmap; + Bitmap maMask; + Size maBitmapSize; + Color maTransparentColor; + TransparentType meTransparent; + bool mbAlpha; + +}; + + +/** Create a blend frame as BitmapEx + + @param nAlpha + The blend value defines how strong the frame will be blended with the + existing content, 255 == full coverage, 0 == no frame will be drawn + + @param aColorTopLeft, aColorBottomRight + The colors defining the frame. These colors are linearly interpolated from + aColorTopLeft and aColorBottomRight using the width and height of the area + + @param rSize + The size of the frame in pixels + */ +BitmapEx VCL_DLLPUBLIC createBlendFrame( + const Size& rSize, + sal_uInt8 nAlpha, + Color aColorTopLeft, + Color aColorBottomRight); + + +/** Create a blend frame as BitmapEx + + @param nAlpha + The blend value defines how strong the frame will be blended with the + existing content, 255 == full coverage, 0 == no frame will be drawn + + @param aColorTopLeft, aColorBottomRight, aColorTopRight, aColorBottomLeft + The colors defining the frame. + + @param rSize + The size of the frame in pixels + */ +BitmapEx createBlendFrame( + const Size& rSize, + sal_uInt8 nAlpha, + Color aColorTopLeft, + Color aColorTopRight, + Color aColorBottomRight, + Color aColorBottomLeft); + +#endif // INCLUDED_VCL_BITMAPEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx new file mode 100644 index 000000000..b2bc2488b --- /dev/null +++ b/include/vcl/builder.hxx @@ -0,0 +1,512 @@ +/* -*- 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_BUILDER_HXX +#define INCLUDED_VCL_BUILDER_HXX + +#include <typeinfo> +#include <sal/log.hxx> +#include <unotools/resmgr.hxx> +#include <tools/fldunit.hxx> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <vcl/vclptr.hxx> +#include <tools/wintypes.hxx> +#include <vcl/EnumContext.hxx> + +#include <memory> +#include <map> +#include <vector> +#ifdef check +# //some problem with MacOSX and a check define +# undef check +#endif + +class Button; +class ComboBox; +class FormattedField; +class ListBox; +class Menu; +class MessageDialog; +class NumericFormatter; +class PopupMenu; +class SalInstanceBuilder; +class ScreenshotTest; +class ScrollBar; +class SvTabListBox; +class Slider; +class DateField; +class TimeField; +class VclExpander; +class VclMultiLineEdit; +struct NotebookBarAddonsItem; +namespace xmlreader { class XmlReader; } +namespace com::sun::star::frame { class XFrame; } + +struct ComboBoxTextItem +{ + OUString m_sItem; + OString m_sId; + ComboBoxTextItem(const OUString& rItem, const OString& rId) + : m_sItem(rItem) + , m_sId(rId) + { + } +}; + +/// Creates a hierarchy of vcl::Windows (widgets) from a .ui file for dialogs, sidebar, etc. +class VCL_DLLPUBLIC VclBuilder +{ +public: + typedef std::map<OString, OUString> stringmap; + typedef std::map<OString, std::pair<OString, OString>> accelmap; + /// These functions create a new widget with parent pParent and return it in rRet + typedef void (*customMakeWidget)(VclPtr<vcl::Window> &rRet, const VclPtr<vcl::Window> &pParent, stringmap &rVec); + +public: + VclBuilder(vcl::Window* pParent, const OUString& sUIRootDir, const OUString& sUIFile, + const OString& sID = OString(), + const css::uno::Reference<css::frame::XFrame>& rFrame + = css::uno::Reference<css::frame::XFrame>(), + bool bLegacy = true, + const NotebookBarAddonsItem* pNotebookBarAddonsItem = nullptr); + ~VclBuilder(); + ///releases references and disposes all children. + void disposeBuilder(); + //sID must exist and be of type T + template <typename T> T* get(VclPtr<T>& ret, const OString& sID); + + //sID may not exist, but must be of type T if it does + template <typename T = vcl::Window> T* get(const OString& sID); + + vcl::Window* get_widget_root(); + + //sID may not exist + PopupMenu* get_menu(const OString& sID); + + //release ownership of pWindow, i.e. don't delete it + void drop_ownership(const vcl::Window *pWindow); + + //see m_aDeferredProperties, you need this for toplevel dialogs + //which build themselves from their ctor. The properties on + //the top level are stored in m_aDeferredProperties and need + //to be applied post ctor + void setDeferredProperties(); + + /// return UI-File name (without '.ui') + const OString& getUIFile() const + { + return m_sHelpRoot; + } + + /// Pre-loads all modules containing UI information + static void preload(); + +private: + VclBuilder(const VclBuilder&) = delete; + VclBuilder& operator=(const VclBuilder&) = delete; + + // owner for ListBox/ComboBox UserData + std::vector<std::unique_ptr<OUString>> m_aUserData; + + //If the toplevel window has any properties which need to be set on it, + //but the toplevel is the owner of the builder, then its ctor + //has not been completed during the building, so properties for it + //are collected here and need to be set afterwards, e.g. during + //Show or Execute + stringmap m_aDeferredProperties; + + std::unique_ptr<NotebookBarAddonsItem> m_pNotebookBarAddonsItem; + + struct PackingData + { + bool m_bVerticalOrient; + sal_Int32 m_nPosition; + PackingData(bool bVerticalOrient = false) + : m_bVerticalOrient(bVerticalOrient) + , m_nPosition(-1) + { + } + }; + + struct WinAndId + { + OString m_sID; + VclPtr<vcl::Window> m_pWindow; + PackingData m_aPackingData; + WinAndId(const OString &rId, vcl::Window *pWindow, bool bVertical) + : m_sID(rId) + , m_pWindow(pWindow) + , m_aPackingData(bVertical) + { + } + }; + std::vector<WinAndId> m_aChildren; + + struct MenuAndId + { + OString m_sID; + VclPtr<Menu> m_pMenu; + MenuAndId(const OString &rId, Menu *pMenu); + }; + std::vector<MenuAndId> m_aMenus; + + struct StringPair + { + OString m_sID; + OString m_sValue; + StringPair(const OString &rId, const OString &rValue) + : m_sID(rId) + , m_sValue(rValue) + { + } + }; + + struct UStringPair + { + OString m_sID; + OUString m_sValue; + UStringPair(const OString &rId, const OUString &rValue) + : m_sID(rId) + , m_sValue(rValue) + { + } + }; + + typedef StringPair RadioButtonGroupMap; + + struct ButtonImageWidgetMap + { + OString m_sID; + OUString m_sValue; + bool m_bRadio; + ButtonImageWidgetMap(const OString &rId, const OUString &rValue, bool bRadio) + : m_sID(rId) + , m_sValue(rValue) + , m_bRadio(bRadio) + { + } + }; + + typedef UStringPair TextBufferMap; + typedef UStringPair WidgetAdjustmentMap; + typedef UStringPair ButtonMenuMap; + typedef UStringPair MnemonicWidgetMap; + + struct ComboBoxModelMap + { + OString m_sID; + OUString m_sValue; + sal_Int32 m_nActiveId; + ComboBoxModelMap(const OString &rId, const OUString &rValue, sal_Int32 nActiveId) + : m_sID(rId) + , m_sValue(rValue) + , m_nActiveId(nActiveId) + { + } + }; + + struct ListStore + { + typedef std::vector<OUString> row; + std::vector<row> m_aEntries; + }; + + const ListStore* get_model_by_name(const OString& sID) const; + void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); + void mungeModel(ComboBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); + void mungeModel(SvTabListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId); + + typedef stringmap TextBuffer; + const TextBuffer* get_buffer_by_name(const OString& sID) const; + + static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer); + + typedef stringmap Adjustment; + const Adjustment* get_adjustment_by_name(const OString& sID) const; + + static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(FormattedField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(ScrollBar &rTarget, const Adjustment &rAdjustment); + static void mungeAdjustment(Slider &rTarget, const Adjustment &rAdjustment); + + struct stockinfo + { + OUString m_sStock; + int m_nSize; + stockinfo() : m_nSize(4) {} + }; + + typedef std::map<OString, stockinfo> StockMap; + + struct SizeGroup + { + std::vector<OString> m_aWidgets; + stringmap m_aProperties; + SizeGroup() {} + }; + + typedef std::map<VclPtr<vcl::Window>, stringmap> AtkMap; + + struct ParserState + { + std::locale m_aResLocale; + + std::vector<RadioButtonGroupMap> m_aGroupMaps; + + std::vector<ComboBoxModelMap> m_aModelMaps; + std::map<OString, ListStore> m_aModels; + + std::vector<TextBufferMap> m_aTextBufferMaps; + std::map<OString, TextBuffer> m_aTextBuffers; + + std::vector<WidgetAdjustmentMap> m_aNumericFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aFormattedFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aTimeFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aDateFormatterAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aScrollAdjustmentMaps; + std::vector<WidgetAdjustmentMap> m_aSliderAdjustmentMaps; + + std::map<OString, Adjustment> m_aAdjustments; + + std::vector<ButtonImageWidgetMap> m_aButtonImageWidgetMaps; + StockMap m_aStockMap; + + std::vector<ButtonMenuMap> m_aButtonMenuMaps; + + std::map<VclPtr<vcl::Window>, VclPtr<vcl::Window>> m_aRedundantParentWidgets; + + std::vector<SizeGroup> m_aSizeGroups; + + AtkMap m_aAtkInfo; + + std::vector<MnemonicWidgetMap> m_aMnemonicWidgetMaps; + + std::vector< VclPtr<VclExpander> > m_aExpanderWidgets; + + std::vector< VclPtr<MessageDialog> > m_aMessageDialogs; + + sal_uInt16 m_nLastToolbarId; + + sal_uInt16 m_nLastMenuItemId; + + ParserState(); + }; + + OString m_sID; + OString m_sHelpRoot; + ResHookProc m_pStringReplace; + VclPtr<vcl::Window> m_pParent; + bool m_bToplevelHasDeferredInit; + bool m_bToplevelHasDeferredProperties; + bool m_bToplevelParentFound; + bool m_bLegacy; + std::unique_ptr<ParserState> m_pParserState; + + vcl::Window *get_by_name(const OString& sID); + void delete_by_name(const OString& sID); + + class sortIntoBestTabTraversalOrder + { + public: + sortIntoBestTabTraversalOrder(VclBuilder *pBuilder) + : m_pBuilder(pBuilder) {} + + bool operator()(const vcl::Window *pA, const vcl::Window *pB) const; + + private: + VclBuilder *m_pBuilder; + }; + + /// XFrame to be able to extract labels and other properties of the UNO commands (like of .uno:Bold). + css::uno::Reference<css::frame::XFrame> m_xFrame; + +private: + VclPtr<vcl::Window> insertObject(vcl::Window *pParent, + const OString &rClass, const OString &rID, + stringmap &rProps, stringmap &rPangoAttributes, + stringmap &rAtkProps); + + VclPtr<vcl::Window> makeObject(vcl::Window *pParent, + const OString &rClass, const OString &rID, + stringmap &rVec); + + void connectNumericFormatterAdjustment(const OString &id, const OUString &rAdjustment); + void connectFormattedFormatterAdjustment(const OString &id, const OUString &rAdjustment); + void connectTimeFormatterAdjustment(const OString &id, const OUString &rAdjustment); + void connectDateFormatterAdjustment(const OString &id, const OUString &rAdjustment); + + void extractGroup(const OString &id, stringmap &rVec); + void extractModel(const OString &id, stringmap &rVec); + void extractBuffer(const OString &id, stringmap &rVec); + static bool extractAdjustmentToMap(const OString &id, stringmap &rVec, std::vector<WidgetAdjustmentMap>& rAdjustmentMap); + void extractButtonImage(const OString &id, stringmap &rMap, bool bRadio); + void extractStock(const OString &id, stringmap &rMap); + void extractMnemonicWidget(const OString &id, stringmap &rMap); + + void handleChild(vcl::Window *pParent, xmlreader::XmlReader &reader); + VclPtr<vcl::Window> handleObject(vcl::Window *pParent, xmlreader::XmlReader &reader); + void handlePacking(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); + static std::vector<vcl::EnumContext::Context> handleStyle(xmlreader::XmlReader &reader, int &nPriority); + static OString getStyleClass(xmlreader::XmlReader &reader); + void applyPackingProperty(vcl::Window *pCurrent, vcl::Window *pParent, xmlreader::XmlReader &reader); + void collectProperty(xmlreader::XmlReader &reader, stringmap &rVec) const; + static void collectPangoAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + static void collectAtkRelationAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + static void collectAtkRoleAttribute(xmlreader::XmlReader &reader, stringmap &rMap); + static void collectAccelerator(xmlreader::XmlReader &reader, accelmap &rMap); + + void insertMenuObject( + Menu *pParent, + PopupMenu *pSubMenu, + const OString &rClass, + const OString &rID, + stringmap &rProps, + accelmap &rAccels); + + void handleMenuChild(Menu *pParent, xmlreader::XmlReader &reader); + void handleMenuObject(Menu *pParent, xmlreader::XmlReader &reader); + + void handleListStore(xmlreader::XmlReader &reader, const OString &rID, const OString &rClass); + void handleRow(xmlreader::XmlReader &reader, const OString &rID); + void handleTabChild(vcl::Window *pParent, xmlreader::XmlReader &reader); + VclPtr<Menu> handleMenu(xmlreader::XmlReader &reader, const OString &rID, bool bMenuBar); + std::vector<ComboBoxTextItem> handleItems(xmlreader::XmlReader &reader) const; + + void handleSizeGroup(xmlreader::XmlReader &reader); + + void handleAtkObject(xmlreader::XmlReader &reader, vcl::Window *pWindow); + + void handleActionWidget(xmlreader::XmlReader &reader); + + PackingData get_window_packing_data(const vcl::Window *pWindow) const; + void set_window_packing_position(const vcl::Window *pWindow, sal_Int32 nPosition); + + static vcl::Window* prepareWidgetOwnScrolling(vcl::Window *pParent, WinBits &rWinStyle); + void cleanupWidgetOwnScrolling(vcl::Window *pScrollParent, vcl::Window *pWindow, stringmap &rMap); + + void set_response(const OString& sID, short nResponse); + + OString get_by_window(const vcl::Window *pWindow) const; + void delete_by_window(vcl::Window *pWindow); +}; + +namespace BuilderUtils +{ + //apply the properties of rProps to pWindow + VCL_DLLPUBLIC void set_properties(vcl::Window *pWindow, const VclBuilder::stringmap &rProps); + + //Convert _ gtk markup to ~ vcl markup + VCL_DLLPUBLIC OUString convertMnemonicMarkup(const OUString &rIn); + + VCL_DLLPUBLIC OUString extractCustomProperty(VclBuilder::stringmap &rMap); + + VCL_DLLPUBLIC bool extractDropdown(VclBuilder::stringmap &rMap); + + //add a default value of 25 width-chars to a map if width-chars not set + VCL_DLLPUBLIC void ensureDefaultWidthChars(VclBuilder::stringmap &rMap); + + //Helpers to retrofit all the existing code to the builder + VCL_DLLPUBLIC void reorderWithinParent(std::vector< vcl::Window*>& rChilds, bool bIsButtonBox); + VCL_DLLPUBLIC void reorderWithinParent(vcl::Window &rWindow, sal_uInt16 nNewPosition); + + //Convert an accessibility role name to accessibility role number + VCL_DLLPUBLIC sal_Int16 getRoleFromName(const OString& roleName); +} + +template <typename T> +inline T* VclBuilder::get(VclPtr<T>& ret, const OString& sID) +{ + vcl::Window *w = get_by_name(sID); + SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID << "\" not found in .ui"); + SAL_WARN_IF(!dynamic_cast<T*>(w), + "vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(w); + assert(dynamic_cast<T*>(w)); + ret = static_cast<T*>(w); + return ret.get(); +} + +//sID may not exist, but must be of type T if it does +template <typename T> +inline T* VclBuilder::get(const OString& sID) +{ + vcl::Window *w = get_by_name(sID); + SAL_WARN_IF(w && !dynamic_cast<T*>(w), + "vcl.layout", ".ui widget \"" << sID << "\" needs to correspond to vcl type " << typeid(T).name()); + assert(!w || dynamic_cast<T*>(w)); + return static_cast<T*>(w); +} + + +//helper baseclass to ease retro fitting dialogs/tabpages that load a resource +//to load a .ui file instead +// +//vcl requires the Window Children of a Parent Window to be destroyed before +//the Parent Window. VclBuilderContainer owns the VclBuilder which owns the +//Children Window. So the VclBuilderContainer dtor must be called before +//the Parent Window dtor. +// +//i.e. class Dialog : public SystemWindow, public VclBuilderContainer +//not class Dialog : public VclBuilderContainer, public SystemWindow +// +//With the new 'dispose' framework, it is necessary to force the builder +//dispose before the Window dispose; so a Dialog::dispose() method would +//finish: disposeBuilder(); SystemWindow::dispose() to capture this ordering. + +class VCL_DLLPUBLIC VclBuilderContainer +{ +public: + VclBuilderContainer(); + virtual ~VclBuilderContainer(); + void disposeBuilder(); + + static OUString getUIRootDir(); + + template <typename T> T* get(VclPtr<T>& ret, const OString& sID) + { + return m_pUIBuilder->get<T>(ret, sID); + } + template <typename T = vcl::Window> T* get(const OString & sID) + { + return m_pUIBuilder->get<T>(sID); + } + void setDeferredProperties() + { + if (!m_pUIBuilder) + return; + m_pUIBuilder->setDeferredProperties(); + } + OString getUIFile() const + { + if (m_pUIBuilder) + { + return m_pUIBuilder->getUIFile(); + } + + return OString(); + } + +protected: + std::unique_ptr<VclBuilder> m_pUIBuilder; + + friend class ::SalInstanceBuilder; + friend class ::ScreenshotTest; +}; + +/* + * @return true if rValue is "True", "true", "1", etc. + */ +bool toBool(const OUString &rValue); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/builderfactory.hxx b/include/vcl/builderfactory.hxx new file mode 100644 index 000000000..c6b1b0ccf --- /dev/null +++ b/include/vcl/builderfactory.hxx @@ -0,0 +1,51 @@ +/* -*- 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_BUILDER_FACTORY_HXX +#define INCLUDED_VCL_BUILDER_FACTORY_HXX + +#include <vcl/vclptr.hxx> +#include <vcl/builder.hxx> + +#define VCL_BUILDER_FACTORY(typeName) \ + extern "C" SAL_DLLPUBLIC_EXPORT void make##typeName(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) \ + { \ + static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>, \ + decltype(make##typeName)>); \ + (void)rMap; \ + rRet = VclPtr<typeName>::Create(pParent); \ + } + +#define VCL_BUILDER_FACTORY_ARGS(typeName,arg1) \ + extern "C" SAL_DLLPUBLIC_EXPORT void make##typeName(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) \ + { \ + static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>, \ + decltype(make##typeName)>); \ + (void)rMap; \ + rRet = VclPtr<typeName>::Create(pParent,arg1); \ + } + +#define VCL_BUILDER_FACTORY_CONSTRUCTOR(typeName,arg2) \ + extern "C" SAL_DLLPUBLIC_EXPORT void make##typeName(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) \ + { \ + static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>, \ + decltype(make##typeName)>); \ + OUString sBorder = BuilderUtils::extractCustomProperty(rMap); \ + WinBits wb = arg2; \ + if (!sBorder.isEmpty()) \ + wb |= WB_BORDER; \ + rRet = VclPtr<typeName>::Create(pParent,wb); \ + } + +#define VCL_BUILDER_FACTORY_EXTERN(typeName) \ + extern "C" void make##typeName(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap & rMap) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/builderpage.hxx b/include/vcl/builderpage.hxx new file mode 100644 index 000000000..85d9accd9 --- /dev/null +++ b/include/vcl/builderpage.hxx @@ -0,0 +1,50 @@ +/* -*- 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_BUILDERPAGE_HXX +#define INCLUDED_VCL_BUILDERPAGE_HXX + +#include <vcl/weld.hxx> + +class VCL_DLLPUBLIC BuilderPage +{ +public: + BuilderPage(weld::Widget* pParent, weld::DialogController* pController, + const OUString& rUIXMLDescription, const OString& rID); + virtual ~BuilderPage() COVERITY_NOEXCEPT_FALSE; + + /* The title of the page, in an Assistant the dialog may append this page title to the + dialog title. + + While in a Dialog hosting a single Page it may use the title as + the dialog title. + */ + void SetPageTitle(const OUString& rPageTitle) { m_aPageTitle = rPageTitle; } + const OUString& GetPageTitle() const { return m_aPageTitle; } + + // In a Notebook or Assistant the controller typically calls Activate on entering + // this page, and Deactivate on leaving + virtual void Activate(); + virtual void Deactivate(); + + void SetHelpId(const OString& rHelpId) { m_xContainer->set_help_id(rHelpId); } + OString GetHelpId() const { return m_xContainer->get_help_id(); } + +protected: + weld::DialogController* m_pDialogController; + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Container> m_xContainer; + +private: + OUString m_aPageTitle; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/button.hxx b/include/vcl/button.hxx new file mode 100644 index 000000000..02371c996 --- /dev/null +++ b/include/vcl/button.hxx @@ -0,0 +1,488 @@ +/* -*- 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_BUTTON_HXX +#define INCLUDED_VCL_BUTTON_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/image.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/vclenum.hxx> +#include <memory> +#include <vector> + +namespace com::sun::star::frame { struct FeatureStateEvent; } +template <class T> class VclPtr; + +class Color; +class ImplCommonButtonData; +enum class DrawButtonFlags; + +class VCL_DLLPUBLIC Button : public Control +{ +private: + std::unique_ptr<ImplCommonButtonData> mpButtonData; + Link<Button*,void> maClickHdl; + + /// Command URL (like .uno:Save) in case the button should handle it. + OUString maCommand; + + Button (const Button &) = delete; + Button & operator= (const Button &) = delete; +public: + SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle( WinBits nWinStyle, DrawFlags nDrawFlags ); + SAL_DLLPRIVATE void ImplDrawAlignedImage(OutputDevice* pDev, Point& rPos, Size& rSize, + sal_uLong nImageSep, + DrawTextFlags nTextStyle, tools::Rectangle *pSymbolRect=nullptr, bool bAddImageSep = false ); + SAL_DLLPRIVATE void ImplSetFocusRect( const tools::Rectangle &rFocusRect ); + SAL_DLLPRIVATE const tools::Rectangle& ImplGetFocusRect() const; + SAL_DLLPRIVATE void ImplSetSymbolAlign( SymbolAlign eAlign ); + /// The x-coordinate of the vertical separator line, use in MenuButton subclass only. + SAL_DLLPRIVATE long ImplGetSeparatorX() const; + SAL_DLLPRIVATE void ImplSetSeparatorX( long nX ); + +protected: + explicit Button( WindowType nType ); + +public: + virtual ~Button() override; + virtual void dispose() override; + + virtual void Click(); + + void SetClickHdl( const Link<Button*,void>& rLink ) { maClickHdl = rLink; } + const Link<Button*,void>& GetClickHdl() const { return maClickHdl; } + + /// Setup handler for UNO commands so that commands like .uno:Something are handled automagically by this button. + void SetCommandHandler(const OUString& aCommand); + OUString const & GetCommand() const { return maCommand; } + + void SetModeImage( const Image& rImage ); + Image const & GetModeImage( ) const; + bool HasImage() const; + void SetImageAlign( ImageAlign eAlign ); + ImageAlign GetImageAlign() const; + DrawButtonFlags GetButtonState() const; + DrawButtonFlags& GetButtonState(); + + + bool IsSmallSymbol() const; + void SetSmallSymbol(); + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + /// Sets the button state according to the FeatureStateEvent emitted by a Uno state change. + virtual void statusChanged(const css::frame::FeatureStateEvent& rEvent); + + virtual FactoryFunction GetUITestFactory() const override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + +protected: + + /// Handler for click, in case we want the button to handle uno commands (.uno:Something). + DECL_STATIC_LINK(Button, dispatchCommandHandler, Button*, void); +}; + +enum class PushButtonDropdownStyle +{ + NONE = 0x0000, + MenuButton = 0x0002, //visual down arrow + SplitMenuButton = 0x0003, //visual down arrow and separator line +}; + +class VCL_DLLPUBLIC PushButton : public Button +{ +public: + SAL_DLLPRIVATE void ImplSetDefButton( bool bSet ); + SAL_DLLPRIVATE void ImplDrawPushButtonFrame(vcl::RenderContext& rRenderContext, tools::Rectangle& rRect, DrawButtonFlags nStyle); + SAL_DLLPRIVATE static bool ImplHitTestPushButton(vcl::Window const * pDev, const Point& rPos); + SAL_DLLPRIVATE bool ImplIsDefButton() const; + + explicit PushButton( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void KeyUp( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + void Toggle(); + + void SetSymbol( SymbolType eSymbol ); + SymbolType GetSymbol() const { return meSymbol; } + void SetSymbolAlign( SymbolAlign eAlign ); + + void SetDropDown( PushButtonDropdownStyle nStyle ); + + void SetState( TriState eState ); + TriState GetState() const { return meState; } + virtual void statusChanged(const css::frame::FeatureStateEvent& rEvent) override; + + void Check( bool bCheck = true ); + bool IsChecked() const; + + void SetPressed( bool bPressed ); + bool IsPressed() const { return mbPressed; } + + void EndSelection(); + + Size CalcMinimumSize() const; + virtual Size GetOptimalSize() const override; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual void ShowFocus(const tools::Rectangle& rRect) override; + + void setAction(bool bIsAction) + { + mbIsAction = bIsAction; + } + + bool isAction() const + { + return mbIsAction; + } + +protected: + PushButtonDropdownStyle mnDDStyle; + bool mbIsActive; + + SAL_DLLPRIVATE void ImplInitPushButtonData(); + SAL_DLLPRIVATE static WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); + SAL_DLLPRIVATE void ImplDrawPushButtonContent(OutputDevice* pDev, DrawFlags nDrawFlags, + const tools::Rectangle& rRect, bool bMenuBtnSep, + DrawButtonFlags nButtonFlags); + SAL_DLLPRIVATE void ImplDrawPushButton(vcl::RenderContext& rRenderContext); + using Button::ImplGetTextStyle; + SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle( DrawFlags nDrawFlags ) const; + SAL_DLLPRIVATE bool IsSymbol() const { return ( (meSymbol != SymbolType::DONTKNOW) && (meSymbol != SymbolType::IMAGE) ); } + + PushButton( const PushButton & ) = delete; + PushButton& operator=( const PushButton & ) + = delete; + + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + using Control::ImplInitSettings; + using Window::ImplInit; + + explicit PushButton( WindowType nType ); + + virtual void FillLayoutData() const override; + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + +private: + SymbolType meSymbol; + TriState meState; + bool mbPressed; + bool mbIsAction; +}; + +inline void PushButton::Check( bool bCheck ) +{ + SetState( bCheck ? TRISTATE_TRUE : TRISTATE_FALSE ); +} + +inline bool PushButton::IsChecked() const +{ + return (GetState() == TRISTATE_TRUE); +} + +class VCL_DLLPUBLIC OKButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + OKButton (const OKButton &) = delete; + OKButton & operator= (const OKButton &) = delete; + +public: + explicit OKButton( vcl::Window* pParent, WinBits nStyle = WB_DEFBUTTON ); + + virtual void Click() override; +}; + +class VCL_DLLPUBLIC CancelButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + CancelButton (const CancelButton &) = delete; + CancelButton & operator= (const CancelButton &) = delete; + +public: + explicit CancelButton( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void Click() override; +}; + +class VCL_DLLPUBLIC RadioButton : public Button +{ +private: + friend class VclBuilder; + + std::shared_ptr< std::vector< VclPtr< RadioButton > > > m_xGroup; + tools::Rectangle maStateRect; + tools::Rectangle maMouseRect; + Image maImage; + bool mbChecked; + bool mbRadioCheck; + bool mbStateChanged; + bool mbUsesExplicitGroup; + Link<RadioButton&,void> maToggleHdl; + SAL_DLLPRIVATE void ImplInitRadioButtonData(); + SAL_DLLPRIVATE WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); + SAL_DLLPRIVATE void ImplDrawRadioButtonState(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags, + const Point& rPos, const Size& rSize, + const Size& rImageSize, tools::Rectangle& rStateRect, + tools::Rectangle& rMouseRect ); + SAL_DLLPRIVATE void ImplDrawRadioButton(vcl::RenderContext& rRenderContext ); + SAL_DLLPRIVATE void ImplUncheckAllOther(); + SAL_DLLPRIVATE Size ImplGetRadioImageSize() const; + SAL_DLLPRIVATE long ImplGetImageToTextDistance() const; + + RadioButton(const RadioButton &) = delete; + RadioButton& operator= (const RadioButton &) = delete; + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + +public: + SAL_DLLPRIVATE void ImplCallClick( bool bGrabFocus = false, GetFocusFlags nFocusFlags = GetFocusFlags::NONE ); + +protected: + virtual void FillLayoutData() const override; + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + void ImplAdjustNWFSizes() override; + +public: + /* + bUsesExplicitGroup of true means that group() is used to set what radiobuttons are part of a group + while false means that contiguous radiobuttons are considered part of a group where WB_GROUP designates + the start of the group and all contiguous radiobuttons without WB_GROUP set form the rest of the group. + + true is fairly straightforward, false leads to trick situations and is the legacy case + */ + explicit RadioButton(vcl::Window* pParent, bool bUsesExplicitGroup = true, WinBits nWinStyle = 0); + virtual ~RadioButton() override; + virtual void dispose() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void KeyUp( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + void Toggle(); + + bool IsStateChanged() const { return mbStateChanged; } + + void EnableRadioCheck( bool bRadioCheck ) { mbRadioCheck = bRadioCheck; } + bool IsRadioCheckEnabled() const { return mbRadioCheck; } + + void SetModeRadioImage( const Image& rImage ); + + void SetState( bool bCheck ); + void Check( bool bCheck = true ); + bool IsChecked() const { return mbChecked; } + + static Image GetRadioImage( const AllSettings& rSettings, DrawButtonFlags nFlags ); + + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize() const override; + + void SetToggleHdl( const Link<RadioButton&,void>& rLink ) { maToggleHdl = rLink; } + + /** GetRadioButtonGroup returns a list of pointers to <code>RadioButton</code>s in the same group. + + The pointers in the returned list are valid at the time call returns. However rescheduling + or giving up the SolarMutex may mean events get executed that lead to the pointers getting + invalid. + + @param bIncludeThis + defines whether <code>this</code> is contained in the returned list + + @return + on return contains the <code>RadioButton</code>s + in the same group as this <code>RadioButton</code>. + */ + std::vector<VclPtr<RadioButton> > GetRadioButtonGroup(bool bIncludeThis = true) const; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + /* + * Group this RadioButton with another + */ + void group(RadioButton &rOther); + virtual void ShowFocus(const tools::Rectangle& rRect) override; + + /// Button hes additional stuff that we need to dump too. + boost::property_tree::ptree DumpAsPropertyTree() override; + + virtual FactoryFunction GetUITestFactory() const override; +}; + +class VCL_DLLPUBLIC CheckBox : public Button +{ +private: + tools::Rectangle maStateRect; + tools::Rectangle maMouseRect; + TriState meState; + TriState meSaveValue; + bool mbTriState; + Link<CheckBox&,void> maToggleHdl; + // when mbLegacyNoTextAlign is set then the old behaviour where + // the WB_LEFT, WB_RIGHT & WB_CENTER affect the image placement + // occurs, otherwise the image ( checkbox box ) is placed + // to the left or right ( depending on RTL or LTR settings ) + bool mbLegacyNoTextAlign; + SAL_DLLPRIVATE void ImplInitCheckBoxData(); + SAL_DLLPRIVATE static WinBits ImplInitStyle( const vcl::Window* pPrevWindow, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags, + const Point& rPos, const Size& rSize, + const Size& rImageSize, tools::Rectangle& rStateRect, + tools::Rectangle& rMouseRect ); + SAL_DLLPRIVATE void ImplDrawCheckBox(vcl::RenderContext& rRenderContext ); + SAL_DLLPRIVATE long ImplGetImageToTextDistance() const; + SAL_DLLPRIVATE Size ImplGetCheckImageSize() const; + + CheckBox(const CheckBox &) = delete; + CheckBox& operator= (const CheckBox &) = delete; + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + virtual void FillLayoutData() const override; + virtual const vcl::Font& GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + void ImplAdjustNWFSizes() override; + + virtual void ImplDrawCheckBoxState(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE const tools::Rectangle& GetStateRect() const { return maStateRect; } + SAL_DLLPRIVATE const tools::Rectangle& GetMouseRect() const { return maMouseRect; } + +public: + SAL_DLLPRIVATE void ImplCheck(); +public: + explicit CheckBox( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void KeyUp( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + void Toggle(); + + void SetState( TriState eState ); + TriState GetState() const { return meState; } + + void Check( bool bCheck = true ); + bool IsChecked() const; + + void EnableTriState( bool bTriState = true ); + bool IsTriStateEnabled() const { return mbTriState; } + + void SaveValue() { meSaveValue = GetState(); } + TriState GetSavedValue() const { return meSaveValue; } + bool IsValueChangedFromSaved() const { return meSaveValue != GetState(); } + + static Image GetCheckImage( const AllSettings& rSettings, DrawButtonFlags nFlags ); + + Size CalcMinimumSize( long nMaxWidth = 0 ) const; + virtual Size GetOptimalSize() const override; + + void SetToggleHdl( const Link<CheckBox&,void>& rLink ) { maToggleHdl = rLink; } + void SetLegacyNoTextAlign( bool bVal ) { mbLegacyNoTextAlign = bVal; } + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual void ShowFocus(const tools::Rectangle& rRect) override; + + /// Button hes additional stuff that we need to dump too. + boost::property_tree::ptree DumpAsPropertyTree() override; + + virtual FactoryFunction GetUITestFactory() const override; +}; + +inline void CheckBox::Check( bool bCheck ) +{ + SetState( bCheck ? TRISTATE_TRUE : TRISTATE_FALSE ); +} + +inline bool CheckBox::IsChecked() const +{ + return (GetState() == TRISTATE_TRUE); +} + +class VCL_DLLPUBLIC ImageButton final : public PushButton +{ +protected: + using PushButton::ImplInitStyle; + +private: + SAL_DLLPRIVATE void ImplInitStyle(); + + ImageButton( const ImageButton & ) = delete; + ImageButton & operator= ( const ImageButton & ) = delete; + +public: + ImageButton( vcl::Window* pParent, WinBits nStyle = 0 ); +}; + +#endif // INCLUDED_VCL_BUTTON_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/cairo.hxx b/include/vcl/cairo.hxx new file mode 100644 index 000000000..87d820ab8 --- /dev/null +++ b/include/vcl/cairo.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_CAIRO_HXX +#define INCLUDED_VCL_CAIRO_HXX + +#include <sal/config.h> +#include <vcl/vclptr.hxx> +#include <memory> + +typedef struct _cairo_surface cairo_surface_t; +typedef struct _cairo cairo_t; + +class VirtualDevice; + +namespace cairo { + + typedef std::shared_ptr<cairo_surface_t> CairoSurfaceSharedPtr; + typedef std::shared_ptr<cairo_t> CairoSharedPtr; + struct Surface; + typedef std::shared_ptr<Surface> SurfaceSharedPtr; + + /** Cairo surface interface + + For each cairo-supported platform, there's an implementation of + this interface + */ + struct Surface + { + public: + virtual ~Surface() {} + + // Query methods + virtual CairoSharedPtr getCairo() const = 0; + virtual CairoSurfaceSharedPtr getCairoSurface() const = 0; + virtual SurfaceSharedPtr getSimilar(int cairo_content_type, int width, int height) const = 0; + + /// factory for VirDev on this surface + virtual VclPtr<VirtualDevice> createVirtualDevice() const = 0; + + /// Resize the surface (possibly destroying content), only possible for X11 typically + /// so on failure caller must create a new surface instead + virtual bool Resize( int /*width*/, int /*height*/ ) { return false; } + + /// Flush all pending output to surface + virtual void flush() const = 0; + }; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/calendar.hxx b/include/vcl/calendar.hxx new file mode 100644 index 000000000..aef21d674 --- /dev/null +++ b/include/vcl/calendar.hxx @@ -0,0 +1,238 @@ +/* -*- 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_CALENDAR_HXX +#define INCLUDED_VCL_CALENDAR_HXX + +#include <vcl/dllapi.h> +#include <unotools/calendarwrapper.hxx> + +#include <vcl/ctrl.hxx> +#include <memory> +#include <set> + +class MouseEvent; +class TrackingEvent; +class KeyEvent; +class HelpEvent; +class DataChangedEvent; + +/************************************************************************* + +Description +============ + +class Calendar + +This class allows for the selection of a date. The displayed date range is +the one specified by the Date class. We display as many months as we have +space in the control. The user can switch between months using a ContextMenu +(clicking on the month's name) or via two ScrollButtons in-between the months. + +-------------------------------------------------------------------------- + +WinBits + +WB_BORDER We draw a border around the window. +WB_TABSTOP Keyboard control is possible. We get the focus, when + the user clicks in the Control. + +-------------------------------------------------------------------------- + +We set and get the selected date by SetCurDate()/GetCurDate(). +If the user selects a date Select() is called. If the user double clicks +DoubleClick() is called. + +-------------------------------------------------------------------------- + +CalcWindowSizePixel() calculates the window size in pixel that is needed +to display a certain number of months. + +-------------------------------------------------------------------------- + +SetSaturdayColor() and SetSundayColor() set a special color for Saturdays +and Sundays. +AddDateInfo() marks special days. With that we can set e.g. public holidays +to another color or encircle them (for e.g. appointments). +If we do not supply a year in the date, the day is used in EVERY year. + +AddDateInfo() can also add text for every date, which is displayed if the +BalloonHelp is enabled. +In order to not have to supply all years with the relevant data, we call +the RequestDateInfo() handler if a new year is displayed. We can then query +the year in the handler with GetRequestYear(). + +-------------------------------------------------------------------------- + +In order to display a ContextMenu for a date, we need to override the +Command handler. GetDate() can infer the date from the mouse's position. +If we use the keyboard, the current date should be use. + +If a ContextMenu is displayed, the baseclass' handler must not be called. + +-------------------------------------------------------------------------- + +SetNoSelection() deselects everything. +SetCurDate() does not select the current date, but only defines the focus +rectangle. +GetSelectDateCount()/GetSelectDate() query the selected range. +IsDateSelected() queries for the status of a date. + +The SelectionChanging() handler is being called while a user selects a +date. In it, we can change the selected range. E.g. if we want to limit +or extend the selected range. The selected range is realised via SelectDate() +and SelectDateRange() and queried with GetSelectDateCount()/GetSelectDate(). + +IsSelectLeft() returns the direction of the selection: +sal_True is a selection to the left or up +sal_False is a selection to the right or down + +-------------------------------------------------------------------------- + +If the DateRange area changes and we want to take over the selection, we +should only do this is if IsScrollDateRangeChanged() returns sal_True. +This method returns sal_True if the area change was triggered by using the +ScrollButtons and sal_False if it was triggered by Resize(), other method +calls or by ending a selection. + +*************************************************************************/ + +typedef std::set<sal_Int32> IntDateSet; + +class VCL_DLLPUBLIC Calendar final : public Control +{ + std::unique_ptr<IntDateSet> mpSelectTable; + std::unique_ptr<IntDateSet> mpOldSelectTable; + OUString maDayTexts[31]; + OUString maDayText; + OUString maWeekText; + CalendarWrapper maCalendarWrapper; + tools::Rectangle maPrevRect; + tools::Rectangle maNextRect; + OUString maDayOfWeekText; + long mnDayOfWeekAry[7]; + Date maOldFormatFirstDate; + Date maOldFormatLastDate; + Date maFirstDate; + Date maOldFirstDate; + Date maCurDate; + Date maOldCurDate; + Color maSelColor; + Color maOtherColor; + sal_Int32 mnDayCount; + long mnDaysOffX; + long mnWeekDayOffY; + long mnDaysOffY; + long mnMonthHeight; + long mnMonthWidth; + long mnMonthPerLine; + long mnLines; + long mnDayWidth; + long mnDayHeight; + WinBits mnWinStyle; + sal_Int16 mnFirstYear; + sal_Int16 mnLastYear; + bool mbCalc:1, + mbFormat:1, + mbDrag:1, + mbSelection:1, + mbMenuDown:1, + mbSpinDown:1, + mbPrevIn:1, + mbNextIn:1, + mbTravelSelect:1, + mbAllSel:1; + Link<Calendar*,void> maSelectHdl; + Link<Calendar*,void> maActivateHdl; + + using Control::ImplInitSettings; + using Window::ImplInit; + VCL_DLLPRIVATE void ImplInit( WinBits nWinStyle ); + VCL_DLLPRIVATE void ImplInitSettings(); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + VCL_DLLPRIVATE void ImplFormat(); + using Window::ImplHitTest; + VCL_DLLPRIVATE sal_uInt16 ImplHitTest( const Point& rPos, Date& rDate ) const; + VCL_DLLPRIVATE void ImplDrawSpin(vcl::RenderContext& rRenderContext); + VCL_DLLPRIVATE void ImplDrawDate(vcl::RenderContext& rRenderContext, long nX, long nY, + sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear, + bool bOther, sal_Int32 nToday); + VCL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); + VCL_DLLPRIVATE void ImplUpdateDate( const Date& rDate ); + VCL_DLLPRIVATE void ImplUpdateSelection( IntDateSet* pOld ); + VCL_DLLPRIVATE void ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest ); + VCL_DLLPRIVATE void ImplUpdate( bool bCalcNew = false ); + using Window::ImplScroll; + VCL_DLLPRIVATE void ImplScroll( bool bPrev ); + VCL_DLLPRIVATE void ImplShowMenu( const Point& rPos, const Date& rDate ); + VCL_DLLPRIVATE void ImplTracking( const Point& rPos, bool bRepeat ); + VCL_DLLPRIVATE void ImplEndTracking( bool bCancel ); + VCL_DLLPRIVATE DayOfWeek ImplGetWeekStart() const; + + virtual Size GetOptimalSize() const override; +public: + Calendar( vcl::Window* pParent, WinBits nWinStyle ); + virtual ~Calendar() override; + virtual void dispose() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void Select(); + + Date GetFirstSelectedDate() const; + void EnableCallEverySelect() { mbAllSel = true; } + + void SetCurDate( const Date& rNewDate ); + void SetFirstDate( const Date& rNewFirstDate ); + const Date& GetFirstDate() const { return maFirstDate; } + Date GetLastDate() const { return GetFirstDate() + mnDayCount; } + Date GetFirstMonth() const; + Date GetLastMonth() const; + sal_uInt16 GetMonthCount() const; + bool GetDate( const Point& rPos, Date& rDate ) const; + tools::Rectangle GetDateRect( const Date& rDate ) const; + + void StartSelection(); + void EndSelection(); + + bool IsTravelSelect() const { return mbTravelSelect; } + + Size CalcWindowSizePixel() const; + + void SetSelectHdl( const Link<Calendar*,void>& rLink ) { maSelectHdl = rLink; } + void SetActivateHdl( const Link<Calendar*,void>& rLink ) { maActivateHdl = rLink; } +}; + +#endif // INCLUDED_VCL_CALENDAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/canvastools.hxx b/include/vcl/canvastools.hxx new file mode 100644 index 000000000..80a15cffd --- /dev/null +++ b/include/vcl/canvastools.hxx @@ -0,0 +1,169 @@ +/* -*- 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_CANVASTOOLS_HXX +#define INCLUDED_VCL_CANVASTOOLS_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <basegfx/numeric/ftools.hxx> +#include <basegfx/range/b2irectangle.hxx> + +#include <vcl/dllapi.h> + +class Point; +class Size; +namespace tools { class Rectangle; } +class BitmapEx; +class Color; + +namespace basegfx +{ + class B2DVector; + class B2DPoint; + class B2DRange; + class B2IPoint; + class B2IRange; +} + +namespace com::sun::star::geometry +{ + struct RealSize2D; + struct IntegerPoint2D; + struct IntegerSize2D; + struct IntegerRectangle2D; +} + +namespace com::sun::star::rendering +{ + class XBitmap; + class XIntegerReadOnlyBitmap; +} + +namespace com::sun::star::rendering { class XColorSpace; } + +namespace vcl +{ + namespace unotools + { + // Bitmap conversions + + + /** Create an XBitmap from VCL BitmapEx + */ + css::uno::Reference< css::rendering::XBitmap > + VCL_DLLPUBLIC xBitmapFromBitmapEx( const ::BitmapEx& inputBitmap ); + + /** Create a BitmapEx from an XBitmap + */ + ::BitmapEx VCL_DLLPUBLIC bitmapExFromXBitmap( const css::uno::Reference< css::rendering::XIntegerReadOnlyBitmap >& xInputBitmap ); + + // Color conversions (vcl/tools Color <-> canvas standard color space) + + + /** Create a device-specific color sequence from VCL/Tools color + + Note that this method assumes a color space equivalent to + the one returned from createStandardColorSpace() + */ + css::uno::Sequence< double > + VCL_DLLPUBLIC colorToStdColorSpaceSequence( const Color& rColor ); + + /** Convert color to device color sequence + + @param rColor + Color to convert + + @param xColorSpace + Color space to convert into + */ + css::uno::Sequence< double > + VCL_DLLPUBLIC colorToDoubleSequence( const Color& rColor, + const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace ); + + /** Convert from standard device color space to VCL/Tools color + + Note that this method assumes a color space equivalent to + the one returned from createStandardColorSpace() + */ + Color VCL_DLLPUBLIC stdColorSpaceSequenceToColor( + const css::uno::Sequence< double >& rColor ); + + /** Convert color to device color sequence + + @param rColor + Color sequence to convert from + + @param xColorSpace + Color space to convert from + */ + Color VCL_DLLPUBLIC doubleSequenceToColor( const css::uno::Sequence< double >& rColor, + const css::uno::Reference< css::rendering::XColorSpace >& xColorSpace ); + + /// Convert [0,1] double value to [0,255] int + inline sal_Int8 toByteColor( double val ) + { + return sal::static_int_cast<sal_Int8>( + basegfx::fround(val*255.0)); + } + + /// Convert [0,255] int value to [0,1] double value + inline double toDoubleColor( sal_uInt8 val ) + { + return val / 255.0; + } + + /// Create a standard color space suitable for VCL RGB color + css::uno::Reference< css::rendering::XColorSpace> VCL_DLLPUBLIC createStandardColorSpace(); + + // Geometry conversions (vcl/tools <-> x) + + + // geometry::Real + css::geometry::RealSize2D VCL_DLLPUBLIC size2DFromSize( const Size& ); + + Size VCL_DLLPUBLIC sizeFromRealSize2D( const css::geometry::RealSize2D& ); + + // geometry::Integer + css::geometry::IntegerSize2D VCL_DLLPUBLIC integerSize2DFromSize( const Size& ); + + Size VCL_DLLPUBLIC sizeFromIntegerSize2D( const css::geometry::IntegerSize2D& ); + Point VCL_DLLPUBLIC pointFromIntegerPoint2D( const css::geometry::IntegerPoint2D& ); + tools::Rectangle VCL_DLLPUBLIC rectangleFromIntegerRectangle2D( const css::geometry::IntegerRectangle2D& ); + + // basegfx::B2D + Size VCL_DLLPUBLIC sizeFromB2DSize( const basegfx::B2DVector& ); + Point VCL_DLLPUBLIC pointFromB2DPoint( const basegfx::B2DPoint& ); + tools::Rectangle VCL_DLLPUBLIC rectangleFromB2DRectangle( const basegfx::B2DRange& ); + + basegfx::B2DVector VCL_DLLPUBLIC b2DSizeFromSize( const Size& ); + basegfx::B2DPoint VCL_DLLPUBLIC b2DPointFromPoint( const Point& ); + basegfx::B2DRange VCL_DLLPUBLIC b2DRectangleFromRectangle( const tools::Rectangle& ); + + // basegfx::B2I + Point VCL_DLLPUBLIC pointFromB2IPoint( const basegfx::B2IPoint& ); + tools::Rectangle VCL_DLLPUBLIC rectangleFromB2IRectangle( const basegfx::B2IRange& ); + basegfx::B2IPoint VCL_DLLPUBLIC b2IPointFromPoint(const Point&); + basegfx::B2IRectangle VCL_DLLPUBLIC b2IRectangleFromRectangle(const tools::Rectangle&); + } +} + +#endif // INCLUDED_VCL_CANVASTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/checksum.hxx b/include/vcl/checksum.hxx new file mode 100644 index 000000000..34d8ed77a --- /dev/null +++ b/include/vcl/checksum.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_INC_CHECKSUM_HXX +#define INCLUDED_VCL_INC_CHECKSUM_HXX + +#include <sal/config.h> +#include <sal/types.h> +#include <vcl/dllapi.h> + +#define BITMAP_CHECKSUM_SIZE 8 + +typedef sal_uInt64 BitmapChecksum; +typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE]; + +template< sal_uInt8 N = 0 > +inline void BCToBCOA( BitmapChecksum n, BitmapChecksumOctetArray p ) +{ + p[N] = static_cast<sal_uInt8>(n >> ( 8 * N )); + return BCToBCOA< N + 1 >( n, p ); +} + +template<> +inline void BCToBCOA< BITMAP_CHECKSUM_SIZE >( BitmapChecksum, BitmapChecksumOctetArray ) +{ + return; +} + +extern "C" { + +/*======================================================================== + * + * vcl_crc64 interface. + * + *======================================================================*/ +/** Evaluate CRC64 over given data. + + This function evaluates the CRC polynomial 0xEDB88320. + + @param Crc [in] CRC64 over previous data or zero. + @param Data [in] data buffer. + @param DatLen [in] data buffer length. + @return new CRC64 value. + */ +VCL_DLLPUBLIC sal_uInt64 vcl_crc64 ( + sal_uInt64 Crc, + const void *Data, sal_uInt32 DatLen +) SAL_THROW_EXTERN_C(); + + +const sal_uInt64* vcl_get_crc64_table(); + +} + +inline BitmapChecksum vcl_get_checksum ( + BitmapChecksum Checksum, + const void *Data, + sal_uInt32 DatLen +) +{ + return static_cast<BitmapChecksum>(vcl_crc64( Checksum, Data, DatLen )); +} + + +#endif // INCLUDED_VCL_INC_CHECKSUM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/commandevent.hxx b/include/vcl/commandevent.hxx new file mode 100644 index 000000000..fd834bd82 --- /dev/null +++ b/include/vcl/commandevent.hxx @@ -0,0 +1,354 @@ +/* -*- 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_COMMANDEVENT_HXX +#define INCLUDED_VCL_COMMANDEVENT_HXX + +#include <memory> +#include <tools/gen.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/keycodes.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <rtl/ustring.hxx> +#include <vcl/GestureEvent.hxx> + +class CommandExtTextInputData; +class CommandWheelData; +class CommandScrollData; +class CommandModKeyData; +class CommandDialogData; +class CommandMediaData; +class CommandSelectionChangeData; +class CommandSwipeData; +class CommandLongPressData; +class CommandGestureData; + +enum class CommandEventId; + +enum class ExtTextInputAttr { + NONE = 0x0000, + GrayWaveline = 0x0100, + Underline = 0x0200, + BoldUnderline = 0x0400, + DottedUnderline = 0x0800, + DashDotUnderline = 0x1000, + Highlight = 0x2000, + RedText = 0x4000, + HalfToneText = 0x8000 +}; +namespace o3tl +{ + template<> struct typed_flags<ExtTextInputAttr> : is_typed_flags<ExtTextInputAttr, 0xff00> {}; +} + +#define EXTTEXTINPUT_CURSOR_INVISIBLE (sal_uInt16(0x0001)) +#define EXTTEXTINPUT_CURSOR_OVERWRITE (sal_uInt16(0x0002)) + + +class VCL_DLLPUBLIC CommandEvent +{ +private: + Point maPos; + void* mpData; + CommandEventId mnCommand; + bool mbMouseEvent; + +public: + CommandEvent(); + CommandEvent( const Point& rMousePos, CommandEventId nCmd, + bool bMEvt = false, const void* pCmdData = nullptr ); + + CommandEventId GetCommand() const { return mnCommand; } + const Point& GetMousePosPixel() const { return maPos; } + bool IsMouseEvent() const { return mbMouseEvent; } + void* GetEventData() const { return mpData; } + + const CommandExtTextInputData* GetExtTextInputData() const; + const CommandWheelData* GetWheelData() const; + const CommandScrollData* GetAutoScrollData() const; + const CommandModKeyData* GetModKeyData() const; + const CommandDialogData* GetDialogData() const; + CommandMediaData* GetMediaData() const; + const CommandSelectionChangeData* GetSelectionChangeData() const; + const CommandSwipeData* GetSwipeData() const; + const CommandLongPressData* GetLongPressData() const; + const CommandGestureData* GetGestureData() const; +}; + +class VCL_DLLPUBLIC CommandExtTextInputData +{ +private: + OUString maText; + std::unique_ptr<ExtTextInputAttr[]> mpTextAttr; + sal_Int32 mnCursorPos; + sal_uInt16 mnCursorFlags; + bool mbOnlyCursor; + +public: + CommandExtTextInputData( const OUString& rText, + const ExtTextInputAttr* pTextAttr, + sal_Int32 nCursorPos, + sal_uInt16 nCursorFlags, + bool bOnlyCursor ); + CommandExtTextInputData( const CommandExtTextInputData& rData ); + ~CommandExtTextInputData(); + + const OUString& GetText() const { return maText; } + const ExtTextInputAttr* GetTextAttr() const { return mpTextAttr.get(); } + + sal_Int32 GetCursorPos() const { return mnCursorPos; } + bool IsCursorVisible() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_INVISIBLE) == 0; } + bool IsCursorOverwrite() const { return (mnCursorFlags & EXTTEXTINPUT_CURSOR_OVERWRITE) != 0; } + bool IsOnlyCursorChanged() const { return mbOnlyCursor; } +}; + +class VCL_DLLPUBLIC CommandInputContextData +{ +}; + +enum class CommandWheelMode +{ + NONE = 0, + SCROLL = 1, + ZOOM = 2, + DATAZOOM = 3 +}; + +// Magic value used in mnLines field in CommandWheelData +#define COMMAND_WHEEL_PAGESCROLL (sal_uLong(0xFFFFFFFF)) + +class VCL_DLLPUBLIC CommandWheelData +{ +private: + long mnDelta; + long mnNotchDelta; + double mnLines; + CommandWheelMode mnWheelMode; + sal_uInt16 mnCode; + bool mbHorz; + bool mbDeltaIsPixel; + +public: + CommandWheelData(); + CommandWheelData( long nWheelDelta, long nWheelNotchDelta, + double nScrollLines, + CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier, + bool bHorz, bool bDeltaIsPixel = false ); + + long GetDelta() const { return mnDelta; } + long GetNotchDelta() const { return mnNotchDelta; } + double GetScrollLines() const { return mnLines; } + bool IsHorz() const { return mbHorz; } + bool IsDeltaPixel() const { return mbDeltaIsPixel; } + + CommandWheelMode GetMode() const { return mnWheelMode; } + + sal_uInt16 GetModifier() const + { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); } + bool IsShift() const + { return ((mnCode & KEY_SHIFT) != 0); } + bool IsMod1() const + { return ((mnCode & KEY_MOD1) != 0); } + bool IsMod2() const + { return ((mnCode & KEY_MOD2) != 0); } +}; + +class CommandScrollData +{ +private: + long mnDeltaX; + long mnDeltaY; + +public: + CommandScrollData( long nDeltaX, long nDeltaY ); + + long GetDeltaX() const { return mnDeltaX; } + long GetDeltaY() const { return mnDeltaY; } +}; + +class CommandModKeyData +{ +private: + bool mbDown; + ModKeyFlags mnCode; + +public: + CommandModKeyData( ModKeyFlags nCode, bool bDown ); + + bool IsDown() const { return mbDown; } + bool IsMod1() const { return bool(mnCode & ModKeyFlags::Mod1Msk); } + bool IsMod2() const { return bool(mnCode & ModKeyFlags::Mod2Msk); } + bool IsLeftShift() const { return bool(mnCode & ModKeyFlags::LeftShift); } + bool IsRightShift() const { return bool(mnCode & ModKeyFlags::RightShift); } +}; + +enum class ShowDialogId +{ + Preferences = 1, + About = 2, +}; + +class VCL_DLLPUBLIC CommandDialogData +{ + ShowDialogId m_nDialogId; +public: + CommandDialogData( ShowDialogId nDialogId ) + : m_nDialogId( nDialogId ) + {} + + ShowDialogId GetDialogId() const { return m_nDialogId; } +}; + +// Media Commands +enum class MediaCommand +{ + ChannelDown = 1, // Decrement the channel value, for example, for a TV or radio tuner. + ChannelUp = 2, // Increment the channel value, for example, for a TV or radio tuner. + NextTrack = 3, // Go to next media track/slide. + Pause = 4, // Pause. If already paused, take no further action. This is a direct PAUSE command that has no state. + Play = 5, // Begin playing at the current position. If already paused, it will resume. This is a direct PLAY command that has no state. + PlayPause = 6, // Play or pause playback. + PreviousTrack = 7, // Go to previous media track/slide. + Record = 8, // Begin recording the current stream. + Rewind = 9,// Go backward in a stream at a higher rate of speed. + Stop = 10,// Stop playback. + MicOnOffToggle = 11,// Toggle the microphone. + MicrophoneVolumeDown = 12,// Increase microphone volume. + MicrophoneVolumeMute = 13,// Mute the microphone. + MicrophoneVolumeUp = 14,// Decrease microphone volume. + VolumeDown = 15,// Lower the volume. + VolumeMute = 16,// Mute the volume. + VolumeUp = 17,// Raise the volume. + Menu = 18,// Button Menu pressed. + PlayHold = 20,// Button Play (long) pressed. + NextTrackHold = 21,// Button Right holding pressed. +}; + +class VCL_DLLPUBLIC CommandMediaData +{ + MediaCommand m_nMediaId; + bool m_bPassThroughToOS; +public: + CommandMediaData(MediaCommand nMediaId) + : m_nMediaId(nMediaId) + , m_bPassThroughToOS(true) + { + } + MediaCommand GetMediaId() const { return m_nMediaId; } + void SetPassThroughToOS(bool bPassThroughToOS) { m_bPassThroughToOS = bPassThroughToOS; } + bool GetPassThroughToOS() const { return m_bPassThroughToOS; } +}; + +class CommandSelectionChangeData +{ +private: + sal_uLong mnStart; + sal_uLong mnEnd; + +public: + CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd ); + + sal_uLong GetStart() const { return mnStart; } + sal_uLong GetEnd() const { return mnEnd; } +}; + +class VCL_DLLPUBLIC CommandSwipeData +{ + double mnVelocityX; +public: + CommandSwipeData() + : mnVelocityX(0) + { + } + CommandSwipeData(double nVelocityX) + : mnVelocityX(nVelocityX) + { + } + double getVelocityX() const { return mnVelocityX; } +}; + + +class VCL_DLLPUBLIC CommandLongPressData +{ + double mnX; + double mnY; +public: + CommandLongPressData() + : mnX(0) + , mnY(0) + { + } + CommandLongPressData(double nX, double nY) + : mnX(nX) + , mnY(nY) + { + } + double getX() const { return mnX; } + double getY() const { return mnY; } +}; + +class VCL_DLLPUBLIC CommandGestureData +{ +public: + double const mfX; + double const mfY; + GestureEventType const meEventType; + + double const mfOffset; + PanningOrientation const meOrientation; + + CommandGestureData(double fX, double fY, GestureEventType eEventType, double fOffset, PanningOrientation eOrientation) + : mfX(fX) + , mfY(fY) + , meEventType(eEventType) + , mfOffset(fOffset) + , meOrientation(eOrientation) + {} +}; + +enum class CommandEventId +{ + NONE = 0, + ContextMenu = 1, + StartDrag = 2, + Wheel = 3, + StartAutoScroll = 4, + AutoScroll = 5, + StartExtTextInput = 7, + ExtTextInput = 8, + EndExtTextInput = 9, + InputContextChange = 10, + CursorPos = 11, + PasteSelection = 12, + ModKeyChange = 13, + InputLanguageChange = 15, + ShowDialog = 16, + Media = 17, + SelectionChange = 18, + PrepareReconversion = 19, + QueryCharPosition = 20, + Swipe = 21, + LongPress = 22, + Gesture = 23, +}; + +#endif // INCLUDED_VCL_COMMANDEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx new file mode 100644 index 000000000..016e53f79 --- /dev/null +++ b/include/vcl/commandinfoprovider.hxx @@ -0,0 +1,107 @@ +/* -*- 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_COMMANDINFOPROVIDER_HXX +#define INCLUDED_VCL_COMMANDINFOPROVIDER_HXX + +#include <vcl/dllapi.h> +#include <vcl/image.hxx> +#include <vcl/keycod.hxx> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::beans { struct PropertyValue; } + +namespace vcl::CommandInfoProvider { + + /** Return a label for the given command. + @param rsCommandName + The command name is expected to start with .uno: + @param rsModuleName + The current application module. + @return + The command properties. + */ + VCL_DLLPUBLIC css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties(const OUString& rsCommandName, const OUString& rsModuleName); + + /** Return a label for the given command. + @param rProperties + The properties from GetCommandProperties. + @return + The command label. + */ + VCL_DLLPUBLIC OUString GetLabelForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties); + + VCL_DLLPUBLIC OUString GetMenuLabelForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties); + + VCL_DLLPUBLIC OUString GetPopupLabelForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties); + + VCL_DLLPUBLIC OUString GetTooltipLabelForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties); + + /** Return a tooltip for the given command. Falls back to label if command has no tooltip. + @param rsCommandName + The command name is expected to start with .uno: + @param rProperties + The properties from GetCommandProperties. + @param rxFrame + The frame is used to identify the module and document. + @return + The returned label contains the keyboard accelerator, if + one is defined and bIncludeShortcut is true. + */ + VCL_DLLPUBLIC OUString GetTooltipForCommand ( + const OUString& rsCommandName, + const css::uno::Sequence<css::beans::PropertyValue>& rProperties, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + /** Returns the shortcut for a command in human-readable form */ + VCL_DLLPUBLIC OUString GetCommandShortcut (const OUString& rCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + VCL_DLLPUBLIC KeyCode GetCommandKeyCodeShortcut (const OUString& rCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame); + + VCL_DLLPUBLIC OUString GetRealCommandForCommand(const css::uno::Sequence<css::beans::PropertyValue>& rProperties); + + VCL_DLLPUBLIC css::uno::Reference<css::graphic::XGraphic> GetXGraphicForCommand( + const OUString& rsCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::ImageType eImageType = vcl::ImageType::Small); + + VCL_DLLPUBLIC Image GetImageForCommand( + const OUString& rsCommandName, + const css::uno::Reference<css::frame::XFrame>& rxFrame, + vcl::ImageType eImageType = vcl::ImageType::Small); + + VCL_DLLPUBLIC sal_Int32 GetPropertiesForCommand( + const OUString& rsCommandName, + const OUString& rsModuleName); + + VCL_DLLPUBLIC bool IsRotated(const OUString& rsCommandName, const OUString& rsModuleName); + VCL_DLLPUBLIC bool IsMirrored(const OUString& rsCommandName, const OUString& rsModuleName); + + /** Returns whether the command is experimental. */ + VCL_DLLPUBLIC bool IsExperimental( + const OUString& rsCommandName, + const OUString& rModuleName); + + VCL_DLLPUBLIC OUString GetModuleIdentifier(const css::uno::Reference<css::frame::XFrame>& rxFrame); +} + +#endif // INCLUDED_VCL_COMMANDINFOPROVIDER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx new file mode 100644 index 000000000..3b734e494 --- /dev/null +++ b/include/vcl/ctrl.hxx @@ -0,0 +1,186 @@ +/* -*- 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_CTRL_HXX +#define INCLUDED_VCL_CTRL_HXX + +#include <tools/link.hxx> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <memory> + +// forward +namespace vcl { struct ImplControlData; } +class StyleSettings; + + +class VCL_DLLPUBLIC Control : public vcl::Window +{ +protected: + std::unique_ptr<vcl::ImplControlData> mpControlData; + +private: + bool mbHasControlFocus; + bool mbShowAccelerator; + Link<Control&,void> maLoseFocusHdl; + + SAL_DLLPRIVATE void ImplInitControlData(); + + Control (const Control &) = delete; + Control & operator= (const Control &) = delete; + +protected: + Control( WindowType nType ); + virtual void FillLayoutData() const; + + // helper method for composite controls + void AppendLayoutData( const Control& rSubControl ) const; + + /// creates the mpData->mpLayoutData structure + void CreateLayoutData() const; + /// determines whether we currently have layout data + bool HasLayoutData() const; + + /** this calls both our event listeners, and a specified handler + + If the Control instance is destroyed during any of those calls, the + method properly handles this (in particular, it doesn't crash :) + + @param nEvent + the event to notify to our event listeners + @param callHandler + the lambda function that calls the handler + @return + if the Control instance has been destroyed in any of the call + */ + bool ImplCallEventListenersAndHandler( + VclEventId nEvent, std::function<void()> const & callHandler + ); + + void CallEventListeners( VclEventId nEvent, void* pData = nullptr ); + + /** draws the given text onto the given device + + If no reference device is set, the draw request will simply be forwarded to OutputDevice::DrawText. Otherwise, + the text will be rendered according to the metrics at the reference device. + + return will contain the result of a GetTextRect call (either directly + at the target device, or taking the reference device into account) when + returning. + */ + tools::Rectangle DrawControlText( OutputDevice& _rTargetDevice, const tools::Rectangle& _rRect, + const OUString& _rStr, DrawTextFlags _nStyle, + MetricVector* _pVector, OUString* _pDisplayText, + const Size* i_pDeviceSize = nullptr ) const; + + tools::Rectangle GetControlTextRect( OutputDevice& _rTargetDevice, const tools::Rectangle & rRect, + const OUString& _rStr, DrawTextFlags _nStyle, + Size* o_pDeviceSize = nullptr ) const; + + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const; + + void ImplInitSettings(); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + SAL_DLLPRIVATE void ImplClearLayoutData() const; + /** draws a frame around the give rectangle, onto the given device + + only to be used from within the Window::Draw method of your sub class. + + The frame is always drawn with a single line (without 3D effects). In addition, any mono + color set at the control's settings is respected. Yet more additionally, if we're living + in a themed desktop, this theming is ignored. + + Note that this makes sense, since the *only known* clients of Window::Draw + are form controls, when printed or print-previewed. For form controls embedded in office documents, + you don't want to have the theme look. + + @param pDev + the device to draw onto + @param rRect + the rect for drawing the frame. Upon returning from the call, the rect will be inflated + by the space occupied by the drawn pixels. + */ + SAL_DLLPRIVATE void ImplDrawFrame( OutputDevice* pDev, tools::Rectangle& rRect ); + +public: + explicit Control( vcl::Window* pParent, WinBits nWinStyle = 0 ); + virtual ~Control() override; + virtual void dispose() override; + + virtual void EnableRTL ( bool bEnable = true ) override; + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void Resize() override; + + // invalidates layout data + virtual void SetText( const OUString& rStr ) override; + // gets the displayed text + virtual OUString GetDisplayText() const override; + // returns the bounding box for the character at index nIndex (in control coordinates) + tools::Rectangle GetCharacterBounds( long nIndex ) const; + // returns the character index for corresponding to rPoint (in control coordinates) + // -1 is returned if no character is at that point + long GetIndexForPoint( const Point& rPoint ) const; + // returns the interval [start,end] of line nLine + // returns [-1,-1] for an invalid line + Pair GetLineStartEnd( long nLine ) const; + /** ToRelativeLineIndex changes a layout data index to a count relative to its line. + + This is equivalent to getting the line start/end pairs with + GetLineStartEnd() until the index lies within [start,end] of a line + + @param nIndex + the absolute index inside the display text to be changed to a relative index + + @returns + the relative index inside the displayed line or -1 if the absolute index does + not match any line + */ + long ToRelativeLineIndex( long nIndex ) const; + + void SetLoseFocusHdl( const Link<Control&,void>& rLink ) { maLoseFocusHdl = rLink; } + + /** determines whether the control currently has the focus + */ + bool HasControlFocus() const { return mbHasControlFocus; } + + void SetLayoutDataParent( const Control* pParent ) const; + + virtual Size GetOptimalSize() const override; + + /** sets a reference device used for rendering control text + @see DrawControlText + */ + void SetReferenceDevice( OutputDevice* _referenceDevice ); + OutputDevice* GetReferenceDevice() const; + + vcl::Font GetUnzoomedControlPointFont() const; + void SetShowAccelerator (bool val); +}; + +#endif // INCLUDED_VCL_CTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/cursor.hxx b/include/vcl/cursor.hxx new file mode 100644 index 000000000..c8e46da80 --- /dev/null +++ b/include/vcl/cursor.hxx @@ -0,0 +1,113 @@ +/* -*- 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_CURSOR_HXX +#define INCLUDED_VCL_CURSOR_HXX + +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <vcl/dllapi.h> +#include <vcl/vclptr.hxx> +#include <rtl/ustring.hxx> +#include <memory> + +class Timer; +struct ImplCursorData; +class OutputDevice; +namespace vcl { class Window; } + +// Cursor styles +#define CURSOR_SHADOW (sal_uInt16(0x0001)) + +enum class CursorDirection +{ + NONE, LTR, RTL +}; + +namespace vcl +{ + +class VCL_DLLPUBLIC Cursor +{ +private: + std::unique_ptr<ImplCursorData> mpData; + VclPtr<vcl::Window> mpWindow; // only for shadow cursor + Size maSize; + Point maPos; + short mnOrientation; + sal_uInt16 mnStyle; + bool mbVisible; + CursorDirection mnDirection; + +public: + SAL_DLLPRIVATE void ImplDraw(); + DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer*, void ); + SAL_DLLPRIVATE void ImplShow(); + SAL_DLLPRIVATE void ImplHide(); + SAL_DLLPRIVATE void ImplResume( bool bRestore = false ); + SAL_DLLPRIVATE bool ImplSuspend(); + SAL_DLLPRIVATE void ImplNew(); + +public: + Cursor(); + Cursor( const Cursor& rCursor ); + ~Cursor(); + + void SetStyle( sal_uInt16 nStyle ); + sal_uInt16 GetStyle() const { return mnStyle; } + + void Show(); + void Hide(); + bool IsVisible() const { return mbVisible; } + + void SetWindow( vcl::Window* pWindow ); + + void SetPos( const Point& rNewPos ); + const Point& GetPos() const { return maPos; } + + void SetSize( const Size& rNewSize ); + const Size& GetSize() const { return maSize; } + void SetWidth( long nNewWidth ); + long GetWidth() const { return maSize.Width(); } + long GetHeight() const { return maSize.Height(); } + + void SetOrientation( short nOrientation = 0 ); + + void SetDirection( CursorDirection nDirection = CursorDirection::NONE ); + + Cursor& operator=( const Cursor& rCursor ); + bool operator==( const Cursor& rCursor ) const; + bool operator!=( const Cursor& rCursor ) const + { return !(Cursor::operator==( rCursor )); } + + void DrawToDevice(OutputDevice& rRenderContext); + +private: + void LOKNotify( vcl::Window* pWindow, const OUString& rAction ); + bool ImplPrepForDraw(const OutputDevice* pDevice, ImplCursorData& rData); + void ImplRestore(); + void ImplDoShow( bool bDrawDirect, bool bRestore ); + bool ImplDoHide( bool bStop ); +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_CURSOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx new file mode 100644 index 000000000..3efcc51d2 --- /dev/null +++ b/include/vcl/customweld.hxx @@ -0,0 +1,174 @@ +/* -*- 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_CUSTOMWELD_HXX +#define INCLUDED_VCL_CUSTOMWELD_HXX + +#include <vcl/weld.hxx> + +class InputContext; + +namespace weld +{ +class VCL_DLLPUBLIC CustomWidgetController +{ +private: + Size m_aSize; + weld::DrawingArea* m_pDrawingArea; + DECL_LINK(DragBeginHdl, weld::DrawingArea&, bool); + +public: + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() + { + return css::uno::Reference<css::accessibility::XAccessible>(); + } + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) = 0; + virtual void Resize() {} + virtual bool MouseButtonDown(const MouseEvent&) { return false; } + virtual bool MouseMove(const MouseEvent&) { return false; } + virtual bool MouseButtonUp(const MouseEvent&) { return false; } + virtual void GetFocus() {} + virtual void LoseFocus() {} + virtual void StyleUpdated() { Invalidate(); } + virtual bool Command(const CommandEvent&) { return false; } + virtual bool KeyInput(const KeyEvent&) { return false; } + virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); } + virtual FactoryFunction GetUITestFactory() const { return nullptr; } + virtual OUString RequestHelp(tools::Rectangle&) { return OUString(); } + virtual OUString GetHelpText() const { return m_pDrawingArea->get_tooltip_text(); } + Size const& GetOutputSizePixel() const { return m_aSize; } + void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; } + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; } + weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; } + void Invalidate() + { + if (!m_pDrawingArea) + return; + m_pDrawingArea->queue_draw(); + } + static bool IsUpdateMode() { return true; } + void Invalidate(const tools::Rectangle& rRect) + { + if (!m_pDrawingArea) + return; + m_pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), + rRect.GetHeight()); + } + virtual void Show() { m_pDrawingArea->show(); } + virtual void Hide() { m_pDrawingArea->hide(); } + void GrabFocus() { m_pDrawingArea->grab_focus(); } + bool HasFocus() const { return m_pDrawingArea->has_focus(); } + bool IsVisible() const { return m_pDrawingArea->get_visible(); } + bool IsReallyVisible() const { return m_pDrawingArea->is_visible(); } + bool IsEnabled() const { return m_pDrawingArea->get_sensitive(); } + void Enable() const { m_pDrawingArea->set_sensitive(true); } + void Disable() const { m_pDrawingArea->set_sensitive(false); } + bool IsActive() const { return m_pDrawingArea->is_active(); } + int GetTextHeight() const { return m_pDrawingArea->get_text_height(); } + OUString GetAccessibleName() const { return m_pDrawingArea->get_accessible_name(); } + OUString GetAccessibleDescription() const + { + return m_pDrawingArea->get_accessible_description(); + } + void CaptureMouse() { m_pDrawingArea->grab_add(); } + bool IsMouseCaptured() const { return m_pDrawingArea->has_grab(); } + void EnableRTL(bool bEnable) { m_pDrawingArea->set_direction(bEnable); } + bool IsRTLEnabled() const { return m_pDrawingArea->get_direction(); } + void ReleaseMouse() { m_pDrawingArea->grab_remove(); } + void SetPointer(PointerStyle ePointerStyle) { m_pDrawingArea->set_cursor(ePointerStyle); } + void SetHelpId(const OString& rHelpId) { m_pDrawingArea->set_help_id(rHelpId); } + void SetAccessibleName(const OUString& rName) { m_pDrawingArea->set_accessible_name(rName); } + void SetInputContext(const InputContext& rInputContext) + { + m_pDrawingArea->set_input_context(rInputContext); + } + void SetCursorRect(const tools::Rectangle& rCursorRect, int nExtTextInputWidth) + { + m_pDrawingArea->im_context_set_cursor_location(rCursorRect, nExtTextInputWidth); + } + virtual int GetSurroundingText(OUString& /*rSurrounding*/) { return -1; } + virtual bool DeleteSurroundingText(const Selection& /*rRange*/) { return false; } + void SetDragDataTransferrable(rtl::Reference<TransferDataContainer>& rTransferrable, + sal_uInt8 eDNDConstants) + { + m_pDrawingArea->enable_drag_source(rTransferrable, eDNDConstants); + m_pDrawingArea->connect_drag_begin(LINK(this, CustomWidgetController, DragBeginHdl)); + } + // return true to disallow drag, false to allow + virtual bool StartDrag() { return false; } + void set_size_request(int nWidth, int nHeight) + { + m_pDrawingArea->set_size_request(nWidth, nHeight); + } + void queue_resize() + { + if (!m_pDrawingArea) + return; + m_pDrawingArea->queue_resize(); + } + CustomWidgetController() + : m_pDrawingArea(nullptr) + { + } + virtual ~CustomWidgetController(); + + CustomWidgetController(CustomWidgetController const&) = default; + CustomWidgetController(CustomWidgetController&&) = default; + CustomWidgetController& operator=(CustomWidgetController const&) = default; + CustomWidgetController& operator=(CustomWidgetController&&) = default; +}; + +class VCL_DLLPUBLIC CustomWeld +{ +private: + weld::CustomWidgetController& m_rWidgetController; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + + DECL_LINK(DoResize, const Size& rSize, void); + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoMouseButtonDown, const MouseEvent&, bool); + DECL_LINK(DoMouseMove, const MouseEvent&, bool); + DECL_LINK(DoMouseButtonUp, const MouseEvent&, bool); + DECL_LINK(DoGetFocus, weld::Widget&, void); + DECL_LINK(DoLoseFocus, weld::Widget&, void); + DECL_LINK(DoKeyPress, const KeyEvent&, bool); + DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle); + DECL_LINK(DoCommand, const CommandEvent&, bool); + DECL_LINK(DoStyleUpdated, weld::Widget&, void); + DECL_LINK(DoRequestHelp, tools::Rectangle&, OUString); + DECL_LINK(DoGetSurrounding, OUString&, int); + +public: + CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId, + CustomWidgetController& rWidgetController); + void queue_draw() { m_xDrawingArea->queue_draw(); } + void queue_draw_area(int x, int y, int width, int height) + { + m_xDrawingArea->queue_draw_area(x, y, width, height); + } + void set_size_request(int nWidth, int nHeight) + { + m_xDrawingArea->set_size_request(nWidth, nHeight); + } + void show() { m_xDrawingArea->show(); } + void hide() { m_xDrawingArea->hide(); } + void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); } + void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); } + void set_sensitive(bool bSensitive) { m_xDrawingArea->set_sensitive(bSensitive); } + bool get_sensitive() const { return m_xDrawingArea->get_sensitive(); } + bool get_visible() const { return m_xDrawingArea->get_visible(); } + void set_visible(bool bVisible) { m_xDrawingArea->set_visible(bVisible); } + void set_grid_left_attach(int nAttach) { m_xDrawingArea->set_grid_left_attach(nAttach); } + int get_grid_left_attach() const { return m_xDrawingArea->get_grid_left_attach(); } + void set_help_id(const OString& rHelpId) { m_xDrawingArea->set_help_id(rHelpId); } +}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/cvtgrf.hxx b/include/vcl/cvtgrf.hxx new file mode 100644 index 000000000..d43a7c0d2 --- /dev/null +++ b/include/vcl/cvtgrf.hxx @@ -0,0 +1,51 @@ +/* -*- 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_CVTGRF_HXX +#define INCLUDED_VCL_CVTGRF_HXX + +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <vcl/salctype.hxx> +#include <vcl/errcode.hxx> + + +class Graphic; + +class VCL_DLLPUBLIC GraphicConverter +{ +private: + + Link<ConvertData&,bool> maFilterHdl; + +public: + + GraphicConverter(); + ~GraphicConverter(); + + static ErrCode Import( SvStream& rIStm, Graphic& rGraphic, ConvertDataFormat nFormat = ConvertDataFormat::Unknown ); + static ErrCode Export( SvStream& rOStm, const Graphic& rGraphic, ConvertDataFormat nFormat ); + + void SetFilterHdl( const Link<ConvertData&,bool>& rLink ) { maFilterHdl = rLink; } + const Link<ConvertData&,bool>& GetFilterHdl() const { return maFilterHdl; } +}; + +#endif // INCLUDED_VCL_CVTGRF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/decoview.hxx b/include/vcl/decoview.hxx new file mode 100644 index 000000000..40dc600b8 --- /dev/null +++ b/include/vcl/decoview.hxx @@ -0,0 +1,110 @@ +/* -*- 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_DECOVIEW_HXX +#define INCLUDED_VCL_DECOVIEW_HXX + +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/vclenum.hxx> +#include <o3tl/typed_flags_set.hxx> + +namespace tools { class Rectangle; } +class Point; +class Color; + +// Flags for DrawSymbol() +enum class DrawSymbolFlags +{ + NONE = 0x0000, + Mono = 0x0001, + Disable = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawSymbolFlags> : is_typed_flags<DrawSymbolFlags, 0x03> {}; +} + +// Flags for DrawFrame() +enum class DrawFrameFlags +{ + NONE = 0x0000, + Menu = 0x0010, + WindowBorder = 0x0020, + BorderWindowBorder = 0x0040, + Mono = 0x1000, + NoDraw = 0x8000, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawFrameFlags> : is_typed_flags<DrawFrameFlags, 0x9070> {}; +} + +// Flags for DrawHighlightFrame() +enum class DrawHighlightFrameStyle +{ + In = 1, + Out = 2, +}; + +// Flags for DrawButton() +enum class DrawButtonFlags +{ + NONE = 0x0000, + Default = 0x0001, + NoLightBorder = 0x0002, + Pressed = 0x0004, + Checked = 0x0008, + DontKnow = 0x0010, + Mono = 0x0020, + Disabled = 0x0040, + Highlight = 0x0100, + Flat = 0x0200, + NoLeftLightBorder = 0x1000 +}; +namespace o3tl +{ + template<> struct typed_flags<DrawButtonFlags> : is_typed_flags<DrawButtonFlags, 0x137f> {}; +} + +class VCL_DLLPUBLIC DecorationView +{ +private: + VclPtr<OutputDevice> mpOutDev; + +public: + DecorationView(OutputDevice* pOutDev); + + void DrawSymbol( const tools::Rectangle& rRect, SymbolType eType, + const Color& rColor, DrawSymbolFlags nStyle = DrawSymbolFlags::NONE ); + void DrawFrame( const tools::Rectangle& rRect, + const Color& rLeftTopColor, + const Color& rRightBottomColor ); + void DrawHighlightFrame( const tools::Rectangle& rRect, + DrawHighlightFrameStyle nStyle ); + tools::Rectangle DrawFrame( const tools::Rectangle& rRect, DrawFrameStyle nStyle = DrawFrameStyle::Out, DrawFrameFlags nFlags = DrawFrameFlags::NONE ); + tools::Rectangle DrawButton( const tools::Rectangle& rRect, DrawButtonFlags nStyle ); + void DrawSeparator( const Point& rStart, const Point& rStop, bool bVertical = true ); + void DrawHandle(const tools::Rectangle& rRectangle); +}; + +#endif // INCLUDED_VCL_DECOVIEW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/devicecoordinate.hxx b/include/vcl/devicecoordinate.hxx new file mode 100644 index 000000000..14e43b22c --- /dev/null +++ b/include/vcl/devicecoordinate.hxx @@ -0,0 +1,28 @@ +/* -*- 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_DEVICE_COORDINATE_HXX +#define INCLUDED_VCL_DEVICE_COORDINATE_HXX + +#include <config_vcl.h> + +#if VCL_FLOAT_DEVICE_PIXEL +#include <basegfx/point/b2dpoint.hxx> +typedef double DeviceCoordinate; + +#else /* !VCL_FLOAT_DEVICE_PIXEL */ + +#include <basegfx/point/b2ipoint.hxx> +typedef long DeviceCoordinate; + +#endif /* ! Carpet Cushion */ + +#endif /* NDef INCLUDED_VCL_DEVICE_COORDINATE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dialoghelper.hxx b/include/vcl/dialoghelper.hxx new file mode 100644 index 000000000..f8d9ffee8 --- /dev/null +++ b/include/vcl/dialoghelper.hxx @@ -0,0 +1,29 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <vcl/dllapi.h> + +namespace vcl +{ +class Window; + +/* cancel dialogs that are a child of pParent + this is used by com.sun.star.embed.DocumentCloser which itself is only used by + extensions/source/activex/SOActiveX.cxx see extensions/source/activex/README.txt + possibly dubious if this actually works as expected +*/ + +VCL_DLLPUBLIC void EndAllDialogs(vcl::Window const* pParent); + +/* for LibreOffice kit */ +VCL_DLLPUBLIC void EnableDialogInput(vcl::Window* pDialog); +VCL_DLLPUBLIC bool CloseDialog(vcl::Window* pDialog); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/dibtools.hxx b/include/vcl/dibtools.hxx new file mode 100644 index 000000000..6064491f8 --- /dev/null +++ b/include/vcl/dibtools.hxx @@ -0,0 +1,87 @@ +/* -*- 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_DIBTOOLS_HXX +#define INCLUDED_VCL_DIBTOOLS_HXX + +#include <vcl/dllapi.h> +#include <vcl/Scanline.hxx> + +// predefines + +class SvStream; +class BitmapEx; +class Bitmap; +class AlphaMask; + +// - Compression defines + +#define COMPRESS_NONE ( 0 ) +#define RLE_8 ( 1 ) +#define RLE_4 ( 2 ) +#define BITFIELDS ( 3UL ) +#define ZCOMPRESS ( ('S'|('D'<<8UL)) | 0x01000000UL ) /* == 'SD01' (binary) */ + +bool VCL_DLLPUBLIC ReadDIB( // ReadDIB(rBitmap, rIStm, true); + Bitmap& rTarget, + SvStream& rIStm, + bool bFileHeader, + bool bMSOFormat=false); + +bool VCL_DLLPUBLIC ReadDIBBitmapEx( + BitmapEx& rTarget, + SvStream& rIStm, + bool bFileHeader = true, + bool bMSOFormat = false); + +bool VCL_DLLPUBLIC ReadDIBV5( + Bitmap& rTarget, + AlphaMask& rTargetAlpha, + SvStream& rIStm); + +bool VCL_DLLPUBLIC ReadRawDIB( + BitmapEx& rTarget, + const unsigned char* pBuf, + const ScanlineFormat nFormat, + const int nHeight, + const int nStride); + + +bool VCL_DLLPUBLIC WriteDIB( + const Bitmap& rSource, + SvStream& rOStm, + bool bCompressed, + bool bFileHeader); + +// compressed, with file header +bool VCL_DLLPUBLIC WriteDIB( + const BitmapEx& rSource, + SvStream& rOStm, + bool bCompressed = true); + +bool VCL_DLLPUBLIC WriteDIBBitmapEx( + const BitmapEx& rSource, + SvStream& rOStm); + +// needed in emfio for emf/wmf migration +sal_uInt32 VCL_DLLPUBLIC getDIBV5HeaderSize(); + +#endif // INCLUDED_VCL_DIBTOOLS_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dllapi.h b/include/vcl/dllapi.h new file mode 100644 index 000000000..805d1cb00 --- /dev/null +++ b/include/vcl/dllapi.h @@ -0,0 +1,47 @@ +/* -*- 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_DLLAPI_H +#define INCLUDED_VCL_DLLAPI_H + +#include <sal/config.h> +#include <sal/types.h> + +#if defined VCL_DLLIMPLEMENTATION +#define VCL_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define VCL_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define VCL_DLLPRIVATE SAL_DLLPRIVATE + +#if defined DLLIMPLEMENTATION_UITEST +#define UITEST_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define UITEST_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + +#if (defined UNX && ! defined MACOS) || defined _WIN32 +#define VCL_PLUGIN_PUBLIC VCL_DLLPUBLIC +#else +#define VCL_PLUGIN_PUBLIC SAL_DLLPRIVATE +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dndhelp.hxx b/include/vcl/dndhelp.hxx new file mode 100644 index 000000000..b5a1d98c7 --- /dev/null +++ b/include/vcl/dndhelp.hxx @@ -0,0 +1,120 @@ +/* -*- 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_DNDHELP_HXX +#define INCLUDED_VCL_DNDHELP_HXX + +#include <vcl/dllapi.h> +#include <cppuhelper/weak.hxx> +#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> + +namespace com { +namespace sun { +namespace star { + +namespace datatransfer { +namespace dnd { + struct DragGestureEvent; + struct DragSourceDragEvent; + struct DragSourceDropEvent; + struct DragSourceEvent; + struct DropTargetDragEvent; + struct DropTargetDragEnterEvent; + struct DropTargetDropEvent; + struct DropTargetEvent; +}} + +}}} + +namespace vcl +{ + +namespace unohelper +{ + +class VCL_DLLPUBLIC DragAndDropClient +{ +public: + virtual ~DragAndDropClient() COVERITY_NOEXCEPT_FALSE; + + // css::datatransfer::dnd::XDragGestureListener + /// @throws css::uno::RuntimeException + virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ); + + // css::datatransfer::dnd::XDragSourceListener + /// @throws css::uno::RuntimeException + virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent& dsde ); + + // css::datatransfer::dnd::XDropTargetListener + /// @throws css::uno::RuntimeException + virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ); + /// @throws css::uno::RuntimeException + virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ); + /// @throws css::uno::RuntimeException + virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ); + /// @throws css::uno::RuntimeException + virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ); +}; + +class VCL_DLLPUBLIC DragAndDropWrapper final : + public css::datatransfer::dnd::XDragGestureListener, + public css::datatransfer::dnd::XDragSourceListener, + public css::datatransfer::dnd::XDropTargetListener, + public ::cppu::OWeakObject +{ +private: + DragAndDropClient* mpClient; + +public: + DragAndDropWrapper( DragAndDropClient* pClient ); + virtual ~DragAndDropWrapper() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() throw() override { OWeakObject::acquire(); } + void SAL_CALL release() throw() override { OWeakObject::release(); } + + // css::lang::XEventListener + void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // css::datatransfer::dnd::XDragGestureListener + void SAL_CALL dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override; + + // css::datatransfer::dnd::XDragSourceListener + void SAL_CALL dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override; + void SAL_CALL dragEnter( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + void SAL_CALL dragExit( const css::datatransfer::dnd::DragSourceEvent& dse ) override; + void SAL_CALL dragOver( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DragSourceDragEvent& dsde ) override; + + // css::datatransfer::dnd::XDropTargetListener + void SAL_CALL drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override; + void SAL_CALL dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override; + void SAL_CALL dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override; + void SAL_CALL dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; + void SAL_CALL dropActionChanged( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; +}; + +}} // namespace vcl::unohelper + +#endif // INCLUDED_VCL_DNDHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dockingarea.hxx b/include/vcl/dockingarea.hxx new file mode 100644 index 000000000..40ffd2852 --- /dev/null +++ b/include/vcl/dockingarea.hxx @@ -0,0 +1,58 @@ +/* -*- 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_DOCKINGAREA_HXX +#define INCLUDED_VCL_DOCKINGAREA_HXX + +#include <config_options.h> +#include <vcl/window.hxx> +#include <memory> + +// A simple container for docked toolbars +// - its main purpose is theming support +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DockingAreaWindow final : public vcl::Window +{ + class SAL_DLLPRIVATE ImplData; + +private: + std::unique_ptr<ImplData> mpImplData; + + DockingAreaWindow (const DockingAreaWindow &) = delete; + DockingAreaWindow & operator= (const DockingAreaWindow &) = delete; + +public: + explicit DockingAreaWindow( vcl::Window* pParent ); + virtual ~DockingAreaWindow() override; + virtual void dispose() override; + + void SetAlign( WindowAlign eNewAlign ); + WindowAlign GetAlign() const; + bool IsHorizontal() const; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + +}; + +#endif // INCLUDED_VCL_DOCKINGAREA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/dockwin.hxx b/include/vcl/dockwin.hxx new file mode 100644 index 000000000..f0f0ee5d6 --- /dev/null +++ b/include/vcl/dockwin.hxx @@ -0,0 +1,381 @@ +/* -*- 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_DOCKWIN_HXX +#define INCLUDED_VCL_DOCKWIN_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <o3tl/deleter.hxx> +#include <vcl/builder.hxx> +#include <vcl/floatwin.hxx> +#include <memory> +#include <vector> + +// data to be sent with docking events +struct DockingData +{ + Point maMousePos; // in + tools::Rectangle maTrackRect; // in/out + bool mbFloating; // out + + DockingData( const Point& rPt, const tools::Rectangle& rRect, bool b) : + maMousePos( rPt ), maTrackRect( rRect ), mbFloating( b ) + {}; +}; + +struct EndDockingData +{ + tools::Rectangle maWindowRect; // in + bool mbFloating; // in + bool mbCancelled; // in + + EndDockingData( const tools::Rectangle& rRect, bool b, bool bCancelled ) : + maWindowRect( rRect ), mbFloating( b ), mbCancelled( bCancelled ) + {}; +}; + +struct EndPopupModeData +{ + Point maFloatingPos; // in + bool mbTearoff; // in + + EndPopupModeData( const Point& rPos, bool bTearoff ) : + maFloatingPos( rPos ), mbTearoff( bTearoff ) + {}; +}; + +/** ImplDockingWindowWrapper + * + * ImplDockingWindowWrapper obsoletes the DockingWindow class. + * It is better because it can make a "normal window" dockable. + * All DockingWindows should be converted the new class. + */ + +class ImplDockingWindowWrapper final +{ + friend class ::vcl::Window; + friend class DockingManager; + friend class DockingWindow; + +private: + + // the original 'Docking'window + VclPtr<vcl::Window> mpDockingWindow; + + // the original DockingWindow members + VclPtr<FloatingWindow> mpFloatWin; + VclPtr<vcl::Window> mpOldBorderWin; + VclPtr<vcl::Window> mpParent; + Point maFloatPos; + Point maDockPos; + Point maMouseOff; + Size maRollUpOutSize; + Size maMinOutSize; + Size maMaxOutSize; + tools::Rectangle maDragArea; + long mnTrackX; + long mnTrackY; + long mnTrackWidth; + long mnTrackHeight; + sal_Int32 mnDockLeft; + sal_Int32 mnDockTop; + sal_Int32 mnDockRight; + sal_Int32 mnDockBottom; + WinBits mnFloatBits; + bool mbDockCanceled:1, + mbDocking:1, + mbLastFloatMode:1, + mbRollUp:1, + mbDockBtn:1, + mbHideBtn:1, + mbStartDockingEnabled:1, + mbLocked:1; + + DECL_LINK( PopupModeEnd, FloatingWindow*, void ); + void ImplEnableStartDocking() { mbStartDockingEnabled = true; } + bool ImplStartDockingEnabled() const { return mbStartDockingEnabled; } + void ImplPreparePopupMode(); + +public: + ImplDockingWindowWrapper( const vcl::Window *pWindow ); + ~ImplDockingWindowWrapper(); + + vcl::Window* GetWindow() { return mpDockingWindow; } + void ImplStartDocking( const Point& rPos ); + + // those methods actually call the corresponding handlers + void StartDocking( const Point& rPos, tools::Rectangle const & rRect ); + bool Docking( const Point& rPos, tools::Rectangle& rRect ); + void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ); + bool PrepareToggleFloatingMode(); + void ToggleFloatingMode(); + + void SetDragArea( const tools::Rectangle& rRect ); + const tools::Rectangle& GetDragArea() const { return maDragArea;} + + void Lock(); + void Unlock(); + bool IsLocked() const { return mbLocked;} + + void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags ); + void StartPopupMode( ToolBox* pParentToolBox, FloatWinPopupFlags nPopupModeFlags ); + bool IsInPopupMode() const; + + void TitleButtonClick( TitleButton nButton ); + void Resizing( Size& rSize ); + void Tracking( const TrackingEvent& rTEvt ); + + void ShowTitleButton( TitleButton nButton, bool bVisible ); + + void SetMinOutputSizePixel( const Size& rSize ); + + void SetMaxOutputSizePixel( const Size& rSize ); + + bool IsDocking() const { return mbDocking; } + bool IsDockingCanceled() const { return mbDockCanceled; } + + void SetFloatingMode( bool bFloatMode ); + bool IsFloatingMode() const; + FloatingWindow* GetFloatingWindow() const { return mpFloatWin; } + + void SetFloatStyle( WinBits nWinStyle ); + WinBits GetFloatStyle() const { return mnFloatBits;} + + void setPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + PosSizeFlags nFlags ); + Point GetPosPixel() const; + Size GetSizePixel() const; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DockingManager +{ + std::vector<std::unique_ptr<ImplDockingWindowWrapper, o3tl::default_delete<ImplDockingWindowWrapper>>> mvDockingWindows; + +public: + DockingManager(); + ~DockingManager(); + + DockingManager& operator=( DockingManager const & ) = delete; // MSVC2015 workaround + DockingManager( DockingManager const & ) = delete; // MSVC2015 workaround + + void AddWindow( const vcl::Window *pWin ); + void RemoveWindow( const vcl::Window *pWin ); + + ImplDockingWindowWrapper* GetDockingWindowWrapper( const vcl::Window *pWin ); + bool IsDockable( const vcl::Window *pWin ); + + bool IsFloating( const vcl::Window *pWin ); + void SetFloatingMode( const vcl::Window *pWin, bool bFloating ); + + void Lock( const vcl::Window *pWin ); + void Unlock( const vcl::Window *pWin ); + bool IsLocked( const vcl::Window *pWin ); + + void StartPopupMode( const vcl::Window *pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags ); + void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin ); + void StartPopupMode( ToolBox *pParentToolBox, const vcl::Window *pWin, FloatWinPopupFlags nPopupModeFlags ); + + bool IsInPopupMode( const vcl::Window *pWin ); + void EndPopupMode( const vcl::Window *pWin ); + + // required because those methods are not virtual in Window (!!!) and must + // be available from the toolkit + void SetPosSizePixel( vcl::Window const *pWin, long nX, long nY, + long nWidth, long nHeight, + PosSizeFlags nFlags ); + tools::Rectangle GetPosSizePixel( const vcl::Window *pWin ); +}; + + +class VCL_DLLPUBLIC DockingWindow + : public vcl::Window + , public VclBuilderContainer +{ + class SAL_DLLPRIVATE ImplData; +private: + VclPtr<FloatingWindow> mpFloatWin; + VclPtr<vcl::Window> mpOldBorderWin; + std::unique_ptr<ImplData> mpImplData; + Point maFloatPos; + Point maDockPos; + Point maMouseOff; + Size maRollUpOutSize; + Size maMinOutSize; + long mnTrackX; + long mnTrackY; + long mnTrackWidth; + long mnTrackHeight; + sal_Int32 mnDockLeft; + sal_Int32 mnDockTop; + sal_Int32 mnDockRight; + sal_Int32 mnDockBottom; + WinBits mnFloatBits; + Idle maLayoutIdle; + bool mbDockCanceled:1, + mbDockable:1, + mbDocking:1, + mbDragFull:1, + mbLastFloatMode:1, + mbStartFloat:1, + mbRollUp:1, + mbDockBtn:1, + mbHideBtn:1, + mbIsCalculatingInitialLayoutSize:1; + +protected: + bool mbIsDeferredInit; + VclPtr<vcl::Window> mpDialogParent; +private: + + SAL_DLLPRIVATE void ImplInitDockingWindowData(); + SAL_DLLPRIVATE void setPosSizeOnContainee(); + DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void ); + + DockingWindow (const DockingWindow &) = delete; + DockingWindow & operator= (const DockingWindow &) = delete; + +protected: + SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName ); + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + + SAL_DLLPRIVATE void DoInitialLayout(); + + void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame); + +public: + bool isLayoutEnabled() const; + void setOptimalLayoutSize(); + + //FIXME: is it okay to make this public? + void ImplStartDocking( const Point& rPos ); + SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; } + virtual void doDeferredInit(WinBits nBits); +protected: + DockingWindow( WindowType nType ); + +public: + DockingWindow(vcl::Window* pParent, WinBits nStyle); + DockingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>()); + virtual ~DockingWindow() override; + virtual void dispose() override; + + virtual void StartDocking(); + virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ); + virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ); + virtual bool PrepareToggleFloatingMode(); + virtual void ToggleFloatingMode(); + + virtual void Resizing( Size& rSize ); + virtual bool Close(); + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void RollDown(); + bool IsRollUp() const; + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const; + + void SetMaxOutputSizePixel( const Size& rSize ); + + bool IsDocking() const { return mbDocking; } + bool IsDockable() const { return mbDockable; } + bool IsDockingCanceled() const { return mbDockCanceled; } + + void SetFloatingMode( bool bFloatMode ); + bool IsFloatingMode() const; + FloatingWindow* GetFloatingWindow() const { return mpFloatWin; } + + void SetFloatingPos( const Point& rNewPos ); + Point GetFloatingPos() const; + + void SetFloatStyle( WinBits nWinStyle ); + WinBits GetFloatStyle() const; + + virtual void setPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + PosSizeFlags nFlags = PosSizeFlags::All ) override; + using Window::SetPosSizePixel; + Point GetPosPixel() const override; + Size GetSizePixel() const override; + void SetOutputSizePixel( const Size& rNewSize ) override; + Size GetOutputSizePixel() const; + + virtual void SetText( const OUString& rStr ) override; + virtual OUString GetText() const override; + virtual Size GetOptimalSize() const override; + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; +}; + + +inline void DockingWindow::RollDown() +{ + if ( mpFloatWin ) + mpFloatWin->RollDown(); + mbRollUp = false; +} + +inline bool DockingWindow::IsRollUp() const +{ + if ( mpFloatWin ) + return mpFloatWin->IsRollUp(); + return mbRollUp; +} + + +inline void DockingWindow::SetMinOutputSizePixel( const Size& rSize ) +{ + if ( mpFloatWin ) + mpFloatWin->SetMinOutputSizePixel( rSize ); + maMinOutSize = rSize; +} + +inline const Size& DockingWindow::GetMinOutputSizePixel() const +{ + if ( mpFloatWin ) + return mpFloatWin->GetMinOutputSizePixel(); + return maMinOutSize; +} + +inline void DockingWindow::SetFloatingPos( const Point& rNewPos ) +{ + if ( mpFloatWin ) + mpFloatWin->SetPosPixel( rNewPos ); + else + maFloatPos = rNewPos; +} + +inline void DockingWindow::SetIdleDebugName( const char *pDebugName ) +{ + maLayoutIdle.SetDebugName( pDebugName ); +} + + +#endif // INCLUDED_VCL_DOCKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/edit.hxx b/include/vcl/edit.hxx new file mode 100644 index 000000000..e48c5748d --- /dev/null +++ b/include/vcl/edit.hxx @@ -0,0 +1,258 @@ +/* -*- 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_EDIT_HXX +#define INCLUDED_VCL_EDIT_HXX + +#include <vcl/ctrl.hxx> +#include <vcl/textfilter.hxx> + +#include <memory> + +#include <rtl/ustrbuf.hxx> +#include <o3tl/deleter.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/menu.hxx> +#include <vcl/dndhelp.hxx> +#include <vcl/vclptr.hxx> +#include <com/sun/star/uno/Reference.h> + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XExtendedInputSequenceChecker; +}}}} +namespace weld { + class Widget; +} + +class VclBuilder; +struct DDInfo; +struct Impl_IMEInfos; + +#define EDIT_NOLIMIT SAL_MAX_INT32 + +class Timer; + +class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient +{ +private: + VclPtr<Edit> mpSubEdit; + TextFilter* mpFilterText; + std::unique_ptr<DDInfo, o3tl::default_delete<DDInfo>> mpDDInfo; + std::unique_ptr<Impl_IMEInfos> mpIMEInfos; + OUStringBuffer maText; + OUString maPlaceholderText; + OUString maSaveValue; + OUString maUndoText; + long mnXOffset; + Selection maSelection; + sal_uInt16 mnAlign; + sal_Int32 mnMaxTextLen; + sal_Int32 mnWidthInChars; + sal_Int32 mnMaxWidthChars; + sal_Unicode mcEchoChar; + bool mbModified:1, + mbInternModified:1, + mbReadOnly:1, + mbInsertMode:1, + mbClickedInSelection:1, + mbIsSubEdit:1, + mbActivePopup:1, + mbForceControlBackground:1, + mbPassword; + Link<Edit&,void> maModifyHdl; + Link<Edit&,void> maAutocompleteHdl; + Link<Edit&,bool> maActivateHdl; + std::unique_ptr<VclBuilder> mpUIBuilder; + + css::uno::Reference<css::i18n::XBreakIterator> mxBreakIterator; + css::uno::Reference<css::i18n::XExtendedInputSequenceChecker> mxISC; + + SAL_DLLPRIVATE bool ImplTruncateToMaxLen( OUString&, sal_Int32 nSelectionLen ) const; + SAL_DLLPRIVATE void ImplInitEditData(); + SAL_DLLPRIVATE void ImplModified(); + SAL_DLLPRIVATE OUString ImplGetText() const; + SAL_DLLPRIVATE void ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle); + SAL_DLLPRIVATE void ImplInvalidateOrRepaint(); + SAL_DLLPRIVATE void ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode ); + SAL_DLLPRIVATE void ImplSetText( const OUString& rStr, const Selection* pNewSelection ); + SAL_DLLPRIVATE void ImplInsertText( const OUString& rStr, const Selection* pNewSelection = nullptr, bool bIsUserInput = false ); + SAL_DLLPRIVATE static OUString ImplGetValidString( const OUString& rString ); + SAL_DLLPRIVATE void ImplClearBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRectangle, long nXStart, long nXEnd); + SAL_DLLPRIVATE void ImplPaintBorder(vcl::RenderContext const & rRenderContext); + SAL_DLLPRIVATE void ImplShowCursor( bool bOnlyIfVisible = true ); + SAL_DLLPRIVATE void ImplAlign(); + SAL_DLLPRIVATE void ImplAlignAndPaint(); + SAL_DLLPRIVATE sal_Int32 ImplGetCharPos( const Point& rWindowPos ) const; + SAL_DLLPRIVATE void ImplSetCursorPos( sal_Int32 nChar, bool bSelect ); + SAL_DLLPRIVATE void ImplShowDDCursor(); + SAL_DLLPRIVATE void ImplHideDDCursor(); + SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKEvt ); + SAL_DLLPRIVATE void ImplCopyToSelectionClipboard(); + SAL_DLLPRIVATE void ImplCopy(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & rxClipboard); + SAL_DLLPRIVATE void ImplPaste(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & rxClipboard); + SAL_DLLPRIVATE long ImplGetTextYPosition() const; + SAL_DLLPRIVATE css::uno::Reference<css::i18n::XExtendedInputSequenceChecker> const& ImplGetInputSequenceChecker(); + SAL_DLLPRIVATE css::uno::Reference<css::i18n::XBreakIterator> const& ImplGetBreakIterator(); + SAL_DLLPRIVATE void filterText(); + +protected: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplSetSelection( const Selection& rSelection, bool bPaint = true ); + SAL_DLLPRIVATE ControlType ImplGetNativeControlType() const; + SAL_DLLPRIVATE long ImplGetExtraXOffset() const; + SAL_DLLPRIVATE long ImplGetExtraYOffset() const; + static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder( vcl::Window* pWin ); + + css::uno::Reference<css::datatransfer::dnd::XDragSourceListener > mxDnDListener; + + // DragAndDropClient + using vcl::unohelper::DragAndDropClient::dragEnter; + using vcl::unohelper::DragAndDropClient::dragExit; + using vcl::unohelper::DragAndDropClient::dragOver; + virtual void dragGestureRecognized(const css::datatransfer::dnd::DragGestureEvent& dge) override; + virtual void dragDropEnd(const css::datatransfer::dnd::DragSourceDropEvent& dsde) override; + virtual void drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde) override; + virtual void dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee) override; + virtual void dragExit(const css::datatransfer::dnd::DropTargetEvent& dte) override; + virtual void dragOver(const css::datatransfer::dnd::DropTargetDragEvent& dtde) override; + +protected: + Edit(WindowType nType); + virtual void FillLayoutData() const override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; +public: + // public because needed in button.cxx + SAL_DLLPRIVATE bool ImplUseNativeBorder(vcl::RenderContext const & rRenderContext, WinBits nStyle); + + Edit( vcl::Window* pParent, WinBits nStyle = WB_BORDER ); + virtual ~Edit() override; + virtual void dispose() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify(); + + static bool IsCharInput( const KeyEvent& rKEvt ); + + virtual void SetModifyFlag(); + virtual void ClearModifyFlag(); + virtual bool IsModified() const { return mpSubEdit ? mpSubEdit->mbModified : mbModified; } + + void SetEchoChar( sal_Unicode c ); + sal_Unicode GetEchoChar() const { return mcEchoChar; } + + virtual void SetReadOnly( bool bReadOnly = true ); + virtual bool IsReadOnly() const { return mbReadOnly; } + + void SetInsertMode( bool bInsert ); + bool IsInsertMode() const; + + virtual void SetMaxTextLen( sal_Int32 nMaxLen ); + virtual sal_Int32 GetMaxTextLen() const { return mnMaxTextLen; } + + void SetWidthInChars(sal_Int32 nWidthInChars); + sal_Int32 GetWidthInChars() const { return mnWidthInChars; } + + void setMaxWidthChars(sal_Int32 nWidth); + + virtual void SetSelection( const Selection& rSelection ); + virtual const Selection& GetSelection() const; + + virtual void ReplaceSelected( const OUString& rStr ); + virtual void DeleteSelected(); + virtual OUString GetSelected() const; + + virtual void Cut(); + virtual void Copy(); + virtual void Paste(); + void Undo(); + + virtual void SetText( const OUString& rStr ) override; + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ); + virtual OUString GetText() const override; + + void SetCursorAtLast(); + + void SetPlaceholderText( const OUString& rStr ); + + void SaveValue() { maSaveValue = GetText(); } + const OUString& GetSavedValue() const { return maSaveValue; } + bool IsValueChangedFromSaved() const { return maSaveValue != GetText(); } + + virtual void SetModifyHdl( const Link<Edit&,void>& rLink ) { maModifyHdl = rLink; } + virtual const Link<Edit&,void>& GetModifyHdl() const { return maModifyHdl; } + + void SetActivateHdl(const Link<Edit&,bool>& rLink) { maActivateHdl = rLink; } + + void SetSubEdit( Edit* pEdit ); + Edit* GetSubEdit() const { return mpSubEdit; } + + void SetAutocompleteHdl( const Link<Edit&,void>& rLink ) { maAutocompleteHdl = rLink; } + const Link<Edit&,void>& GetAutocompleteHdl() const { return maAutocompleteHdl; } + + virtual Size CalcMinimumSize() const; + virtual Size CalcMinimumSizeForText(const OUString &rString) const; + virtual Size GetOptimalSize() const override; + virtual Size CalcSize(sal_Int32 nChars) const; + sal_Int32 GetMaxVisChars() const; + + // shows a warning box saying "text too long, truncated" + static void ShowTruncationWarning(weld::Widget* pParent); + + VclPtr<PopupMenu> CreatePopupMenu(); + + virtual OUString GetSurroundingText() const override; + virtual Selection GetSurroundingTextSelection() const override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + void SetTextFilter(TextFilter* pFilter) { mpFilterText = pFilter; } + + virtual FactoryFunction GetUITestFactory() const override; + + // returns the minimum size a bordered Edit should have given the current + // global style settings (needed by sc's inputwin.cxx) + static Size GetMinimumEditSize(); + + void SetForceControlBackground(bool b) { mbForceControlBackground = b; } + + bool IsPassword() const { return mbPassword; } +}; + +#endif // INCLUDED_VCL_EDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/embeddedfontshelper.hxx b/include/vcl/embeddedfontshelper.hxx new file mode 100644 index 000000000..54123d76a --- /dev/null +++ b/include/vcl/embeddedfontshelper.hxx @@ -0,0 +1,106 @@ +/* -*- 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_EMBEDDEDFONTSHELPER_HXX +#define INCLUDED_VCL_EMBEDDEDFONTSHELPER_HXX + +#include <vcl/dllapi.h> + +#include <rtl/ustring.hxx> +#include <tools/fontenum.hxx> +#include <vector> + +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::uno { template <typename > class Reference; } + +/** + Helper functions for handling embedded fonts in documents. + +*/ +class VCL_DLLPUBLIC EmbeddedFontsHelper +{ +private: + std::vector<std::pair<OUString, OUString>> m_aAccumulatedFonts; + + /** + Adds the given font to the list of known fonts. The font is used only until application + exit. + + @param fontName name of the font (e.g. 'Times New Roman') + @param fileUrl URL of the font file + */ + static void activateFont( const OUString& fontName, const OUString& fileUrl ); + +public: + /// Specification of what kind of operation is allowed when embedding a font + enum class FontRights + { + ViewingAllowed, ///< Font may be embedded for viewing the document (but not editing) + EditingAllowed ///< Font may be embedded for editing document (implies viewing) + }; + + /** + Returns URL for a font file for the given font, or empty if it does not exist. + */ + static OUString fontFileUrl( const OUString& familyName, FontFamily family, FontItalic italic, + FontWeight weight, FontPitch pitch, FontRights rights ); + + /** + Reads a font from the input stream, saves it to a temporary font file and adds it to the list of + fonts that activateFonts will activate. + @param stream stream of font data + @param fontName name of the font (e.g. 'Times New Roman') + @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique + @param key key to xor the data with, from the start until the key's length (not repeated) + @param eot whether the data is compressed in Embedded OpenType format + */ + bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream, + const OUString& fontName, const char* extra, + std::vector< unsigned char > key, bool eot = false); + + /** + Returns a URL for a file where to store contents of a given temporary font. + The file may or not may not exist yet, and will be cleaned up automatically as appropriate. + Use activateTemporaryFont() to actually enable usage of the font. + + @param fontName name of the font (e.g. 'Times New Roman') + @param extra additional text to use for name (e.g. to distinguish regular from bold, italic,...), "?" for unique + */ + static OUString fileUrlForTemporaryFont( const OUString& fontName, const char* extra ); + + /** + Adds the accumulated fonts to the list of known fonts. The fonts are used only until application + exit. + */ + void activateFonts(); + + /** + Returns if the restrictions specified in the font (if present) allow embedding + the font for a particular purpose. + @param data font data + @param size size of the font data + @param rights type of operation to be allowed for the font + */ + static bool sufficientTTFRights( const void* data, long size, FontRights rights ); + + /** + Removes all temporary fonts in the path used by fileUrlForTemporaryFont(). + @internal + */ + static void clearTemporaryFontFiles(); + + ~EmbeddedFontsHelper() + { + activateFonts(); + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/errcode.hxx b/include/vcl/errcode.hxx new file mode 100644 index 000000000..d189f0385 --- /dev/null +++ b/include/vcl/errcode.hxx @@ -0,0 +1,281 @@ +/* -*- 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_ERRCODE_HXX +#define INCLUDED_VCL_ERRCODE_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <ostream> + +/* + +01234567012345670123456701234567 +|| || || || | +Warning || || | + | || || || | + Dynamic || || | + | || || | + Subsystemarea| || | + | || | + | || | + | || | + Class| | + | | + | | + | | + Code +*/ + +#define ERRCODE_ERROR_MASK 0x3fffffffUL +#define ERRCODE_WARNING_MASK 0x80000000UL + +#define ERRCODE_CLASS_SHIFT 8 +#define ERRCODE_AREA_SHIFT 13 +#define ERRCODE_DYNAMIC_SHIFT 26 + +#define ERRCODE_CLASS_MASK (31UL << ERRCODE_CLASS_SHIFT) + +#define ERRCODE_DYNAMIC_COUNT 31UL +#define ERRCODE_DYNAMIC_MASK (31UL << ERRCODE_DYNAMIC_SHIFT) + +enum class ErrCodeArea; +enum class ErrCodeClass; + +enum class WarningFlag { Yes }; + +class SAL_WARN_UNUSED ErrCode final +{ +public: + explicit constexpr ErrCode(WarningFlag, ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode) + : m_value(ERRCODE_WARNING_MASK | (sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode) + { + assert(nCode <= 0xff && "code out of range"); + } + explicit constexpr ErrCode(ErrCodeArea nArea, ErrCodeClass nClass, sal_uInt16 nCode) + : m_value((sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | (sal_uInt32(nClass) << ERRCODE_CLASS_SHIFT) | nCode) + { + assert(nCode <= 0xff && "code out of range"); + } + explicit constexpr ErrCode(ErrCodeArea nArea, sal_uInt16 nClassAndCode) + : m_value((sal_uInt32(nArea) << ERRCODE_AREA_SHIFT) | nClassAndCode) {} + explicit constexpr ErrCode(sal_uInt32 nValue) + : m_value(nValue) {} + constexpr ErrCode() + : m_value(0) {} + + explicit operator sal_uInt32() const { return m_value; } + explicit operator bool() const { return m_value != 0; } + + bool operator<(ErrCode const & other) const { return m_value < other.m_value; } + bool operator<=(ErrCode const & other) const { return m_value <= other.m_value; } + bool operator>(ErrCode const & other) const { return m_value > other.m_value; } + bool operator>=(ErrCode const & other) const { return m_value >= other.m_value; } + bool operator==(ErrCode const & other) const { return m_value == other.m_value; } + bool operator!=(ErrCode const & other) const { return m_value != other.m_value; } + + /** convert to ERRCODE_NONE if it's a warning, else return the error */ + ErrCode IgnoreWarning() const { + return (m_value & ERRCODE_WARNING_MASK) + ? ErrCode(0) + : ErrCode(static_cast<sal_uInt32>(m_value & ERRCODE_ERROR_MASK)); + } + + bool IsWarning() const { + return m_value & ERRCODE_WARNING_MASK; + } + + ErrCode MakeWarning() const { + return ErrCode(m_value | ERRCODE_WARNING_MASK); + } + + bool IsError() const { + return m_value && !IsWarning(); + } + + bool IsDynamic() const { + return m_value & ERRCODE_DYNAMIC_MASK; + } + + sal_uInt32 GetDynamic() const { + return (m_value & ERRCODE_DYNAMIC_MASK) >> ERRCODE_DYNAMIC_SHIFT; + } + + ErrCode StripDynamic() const { + return ErrCode(m_value & ~ERRCODE_DYNAMIC_MASK); + } + + constexpr ErrCode StripWarningAndDynamic() const { + return ErrCode(m_value & ~(ERRCODE_DYNAMIC_MASK | ERRCODE_WARNING_MASK)); + } + + constexpr ErrCodeArea GetArea() const { + return static_cast<ErrCodeArea>((m_value >> ERRCODE_AREA_SHIFT) & 0x01fff); + } + + constexpr ErrCodeClass GetClass() const { + return static_cast<ErrCodeClass>((m_value >> ERRCODE_CLASS_SHIFT) & 0x1f); + } + + constexpr sal_uInt8 GetCode() const { + return static_cast<sal_uInt8>(m_value & 0xff); + } + + OUString toHexString() const { + return "0x" + OUString::number(m_value, 16); + } + + bool anyOf(ErrCode v) const { + return *this == v; + } + + template<typename... Args> + bool anyOf(ErrCode first, Args... args) const { + return *this == first || anyOf(args...); + } +private: + sal_uInt32 m_value; +}; + +VCL_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err); + +enum class ErrCodeArea { + Io = 0 , + Sfx = 2 , + Inet = 3 , + Vcl = 4 , + Svx = 8 , + So = 9 , + Sbx = 10, + Uui = 13, + Sc = 32, + Sd = 40, + Sw = 56, +}; + +enum class ErrCodeClass { + NONE = 0, + Abort = 1, + General = 2, + NotExists = 3, + AlreadyExists = 4, + Access = 5, + Path = 6, + Locking = 7, + Parameter = 8, + Space = 9, + NotSupported = 10, + Read = 11, + Write = 12, + Unknown = 13, + Version = 14, + Format = 15, + Create = 16, + Import = 17, + Export = 18, + So = 20, + Sbx = 21, + Runtime = 22, + Compiler = 23 +}; + +#define ERRCODE_NONE ErrCode(0) + +#define ERRCODE_IO_MISPLACEDCHAR ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 1 ) +#define ERRCODE_IO_NOTEXISTS ErrCode( ErrCodeArea::Io, ErrCodeClass::NotExists, 2 ) +#define ERRCODE_IO_ALREADYEXISTS ErrCode( ErrCodeArea::Io, ErrCodeClass::AlreadyExists, 3 ) +#define ERRCODE_IO_NOTADIRECTORY ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 4 ) +#define ERRCODE_IO_NOTAFILE ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 5 ) +#define ERRCODE_IO_INVALIDDEVICE ErrCode( ErrCodeArea::Io, ErrCodeClass::Path, 6 ) +#define ERRCODE_IO_ACCESSDENIED ErrCode( ErrCodeArea::Io, ErrCodeClass::Access, 7 ) +#define ERRCODE_IO_LOCKVIOLATION ErrCode( ErrCodeArea::Io, ErrCodeClass::Locking, 8 ) +#define ERRCODE_IO_OUTOFSPACE ErrCode( ErrCodeArea::Io, ErrCodeClass::Space, 9 ) +#define ERRCODE_IO_ISWILDCARD ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 11 ) +#define ERRCODE_IO_NOTSUPPORTED ErrCode( ErrCodeArea::Io, ErrCodeClass::NotSupported, 12 ) +#define ERRCODE_IO_GENERAL ErrCode( ErrCodeArea::Io, ErrCodeClass::General, 13 ) +#define ERRCODE_IO_TOOMANYOPENFILES ErrCode( ErrCodeArea::Io, ErrCodeClass::Space, 14 ) +#define ERRCODE_IO_CANTREAD ErrCode( ErrCodeArea::Io, ErrCodeClass::Read, 15 ) +#define ERRCODE_IO_CANTWRITE ErrCode( ErrCodeArea::Io, ErrCodeClass::Write, 16 ) +#define ERRCODE_IO_OUTOFMEMORY ErrCode( ErrCodeArea::Io, ErrCodeClass::Space, 17 ) +#define ERRCODE_IO_CANTSEEK ErrCode( ErrCodeArea::Io, ErrCodeClass::General, 18 ) +#define ERRCODE_IO_CANTTELL ErrCode( ErrCodeArea::Io, ErrCodeClass::General, 19 ) +#define ERRCODE_IO_WRONGVERSION ErrCode( ErrCodeArea::Io, ErrCodeClass::Version, 20 ) +#define ERRCODE_IO_WRONGFORMAT ErrCode( ErrCodeArea::Io, ErrCodeClass::Format, 21 ) +#define ERRCODE_IO_INVALIDCHAR ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 22 ) +#define ERRCODE_IO_UNKNOWN ErrCode( ErrCodeArea::Io, ErrCodeClass::Unknown, 23 ) +#define ERRCODE_IO_INVALIDACCESS ErrCode( ErrCodeArea::Io, ErrCodeClass::Access, 24 ) +#define ERRCODE_IO_CANTCREATE ErrCode( ErrCodeArea::Io, ErrCodeClass::Create, 25 ) +#define ERRCODE_IO_INVALIDPARAMETER ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 26 ) +#define ERRCODE_IO_ABORT ErrCode( ErrCodeArea::Io, ErrCodeClass::Abort, 27 ) +#define ERRCODE_IO_NOTEXISTSPATH ErrCode( ErrCodeArea::Io, ErrCodeClass::NotExists, 28 ) +#define ERRCODE_IO_PENDING ErrCode( ErrCodeArea::Io, ErrCodeClass::NotExists, 29 ) +#define ERRCODE_IO_RECURSIVE ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 30 ) +#define ERRCODE_IO_NAMETOOLONG ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 31 ) +#define ERRCODE_IO_INVALIDLENGTH ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 32 ) +#define ERRCODE_IO_CURRENTDIR ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 33 ) +#define ERRCODE_IO_NOTSAMEDEVICE ErrCode( ErrCodeArea::Io, ErrCodeClass::Parameter, 34 ) +#define ERRCODE_IO_DEVICENOTREADY ErrCode( ErrCodeArea::Io, ErrCodeClass::Read, 35 ) +#define ERRCODE_IO_BADCRC ErrCode( ErrCodeArea::Io, ErrCodeClass::Read, 36 ) +#define ERRCODE_IO_WRITEPROTECTED ErrCode( ErrCodeArea::Io, ErrCodeClass::Access, 37 ) +#define ERRCODE_IO_BROKENPACKAGE ErrCode( ErrCodeArea::Io, ErrCodeClass::Format, 38 ) +#define ERRCODE_IO_NOTSTORABLEINBINARYFORMAT ErrCode( ErrCodeArea::Io, ErrCodeClass::Format, 39 ) +#define ERRCODE_IO_FILTERDISABLED ErrCode( ErrCodeArea::Io, ErrCodeClass::Format, 40 ) + +// StreamErrorCodes + +#define SVSTREAM_GENERALERROR ERRCODE_IO_GENERAL +#define SVSTREAM_FILE_NOT_FOUND ERRCODE_IO_NOTEXISTS +#define SVSTREAM_PATH_NOT_FOUND ERRCODE_IO_NOTEXISTSPATH +#define SVSTREAM_TOO_MANY_OPEN_FILES ERRCODE_IO_TOOMANYOPENFILES +#define SVSTREAM_ACCESS_DENIED ERRCODE_IO_ACCESSDENIED +#define SVSTREAM_SHARING_VIOLATION ERRCODE_IO_LOCKVIOLATION +#define SVSTREAM_LOCKING_VIOLATION ERRCODE_IO_LOCKVIOLATION +#define SVSTREAM_SHARE_BUFF_EXCEEDED ERRCODE_IO_LOCKVIOLATION + +#define SVSTREAM_INVALID_ACCESS ERRCODE_IO_INVALIDACCESS +#define SVSTREAM_INVALID_HANDLE ERRCODE_IO_GENERAL +#define SVSTREAM_CANNOT_MAKE ERRCODE_IO_CANTCREATE +#define SVSTREAM_INVALID_PARAMETER ERRCODE_IO_INVALIDPARAMETER + +#define SVSTREAM_READ_ERROR ERRCODE_IO_CANTREAD +#define SVSTREAM_WRITE_ERROR ERRCODE_IO_CANTWRITE +#define SVSTREAM_SEEK_ERROR ERRCODE_IO_CANTSEEK + +#define SVSTREAM_OUTOFMEMORY ERRCODE_IO_OUTOFMEMORY + +#define SVSTREAM_FILEFORMAT_ERROR ERRCODE_IO_WRONGFORMAT +#define SVSTREAM_WRONGVERSION ERRCODE_IO_WRONGVERSION + +#define SVSTREAM_DISK_FULL ERRCODE_IO_OUTOFSPACE + +#define PRINTER_ABORT ERRCODE_IO_ABORT +#define PRINTER_GENERALERROR ERRCODE_IO_GENERAL + +#define ERRCODE_ABORT ERRCODE_IO_ABORT + +#define ERRCODE_INET_NAME_RESOLVE ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 1) +#define ERRCODE_INET_CONNECT ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 2) +#define ERRCODE_INET_READ ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 3) +#define ERRCODE_INET_WRITE ErrCode(ErrCodeArea::Inet, ErrCodeClass::Write, 4) +#define ERRCODE_INET_GENERAL ErrCode(ErrCodeArea::Inet, ErrCodeClass::Write, 5) +#define ERRCODE_INET_OFFLINE ErrCode(ErrCodeArea::Inet, ErrCodeClass::Read, 6) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/errinf.hxx b/include/vcl/errinf.hxx new file mode 100644 index 000000000..4a0edc75b --- /dev/null +++ b/include/vcl/errinf.hxx @@ -0,0 +1,216 @@ +/* -*- 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_ERRINF_HXX +#define INCLUDED_VCL_ERRINF_HXX + +#include <rtl/ustring.hxx> +#include <vcl/errcode.hxx> +#include <vcl/dllapi.h> +#include <o3tl/typed_flags_set.hxx> + +#include <vector> +#include <memory> + +#include <limits.h> + +namespace weld { class Window; } + +class ErrorHandler; +class ErrorContext; +class ErrorInfo; +class DynamicErrorInfo; +class ImplDynamicErrorInfo; +enum class DialogMask; + +typedef void (* DisplayFnPtr)(); + +typedef DialogMask WindowDisplayErrorFunc( + weld::Window*, DialogMask eMask, const OUString &rErr, const OUString &rAction); + +typedef void BasicDisplayErrorFunc( + const OUString &rErr, const OUString &rAction); + +class VCL_DLLPUBLIC ErrorRegistry +{ + friend class ErrorHandler; + friend class ErrorContext; + friend class ErrorStringFactory; + friend class ImplDynamicErrorInfo; + +public: + ErrorRegistry(); + + static void RegisterDisplay(BasicDisplayErrorFunc*); + static void RegisterDisplay(WindowDisplayErrorFunc*); + static void Reset(); + +private: + DisplayFnPtr pDsp; + bool bIsWindowDsp; + sal_uInt16 nNextError; + + std::vector<ErrorHandler*> errorHandlers; + std::vector<ErrorContext*> contexts; + + DynamicErrorInfo* ppDynErrInfo[ERRCODE_DYNAMIC_COUNT]; +}; + +enum class DialogMask +{ + NONE = 0x0000, + ButtonsOk = 0x0001, + ButtonsCancel = 0x0002, + ButtonsRetry = 0x0004, + ButtonsNo = 0x0008, + ButtonsYes = 0x0010, + ButtonsYesNo = 0x0018, + + ButtonDefaultsOk = 0x0100, + ButtonDefaultsCancel = 0x0200, + ButtonDefaultsYes = 0x0300, + ButtonDefaultsNo = 0x0400, + + MessageError = 0x1000, + MessageWarning = 0x2000, + MessageInfo = 0x3000, + + MAX = USHRT_MAX, +}; +namespace o3tl +{ + template<> struct typed_flags<DialogMask> : is_typed_flags<DialogMask, 0xffff> {}; +} + +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorHandler +{ + friend class ErrorStringFactory; + +public: + ErrorHandler(); + virtual ~ErrorHandler(); + + /** Handles an error. + + If nFlags is not set, the DynamicErrorInfo flags or the + resource flags will be used. Thus the order is: + + 1. nFlags, + 2. Resource Flags + 3. Dynamic Flags + 4. Default ButtonsOk, MessageError + + @param nErrCodeId error id + @param pParent parent window the error dialog will be modal for. nullptr for unrecommended "pick default" + @param nFlags error flags. + + @return what sort of dialog to use, with what buttons + */ + static DialogMask HandleError(ErrCode nId, weld::Window* pParent = nullptr, DialogMask nMask = DialogMask::MAX); + static bool GetErrorString(ErrCode nId, OUString& rStr); + +protected: + virtual bool CreateString(const ErrorInfo*, OUString &) const = 0; + +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorInfo +{ +public: + ErrorInfo(ErrCode nArgUserId) : + nUserId(nArgUserId) {} + virtual ~ErrorInfo(); + + ErrCode const & GetErrorCode() const { return nUserId; } + + static std::unique_ptr<ErrorInfo> GetErrorInfo(ErrCode); + +private: + ErrCode nUserId; +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC DynamicErrorInfo : public ErrorInfo +{ + friend class ImplDynamicErrorInfo; + +public: + DynamicErrorInfo(ErrCode nUserId, DialogMask nMask); + virtual ~DynamicErrorInfo() override; + + operator ErrCode() const; + DialogMask GetDialogMask() const; + +private: + std::unique_ptr<ImplDynamicErrorInfo> pImpl; + +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC StringErrorInfo final : public DynamicErrorInfo +{ +public: + StringErrorInfo(ErrCode nUserId, + const OUString& aStringP, + DialogMask nMask = DialogMask::NONE); + + const OUString& GetErrorString() const { return aString; } + +private: + OUString aString; + +}; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC TwoStringErrorInfo final : public DynamicErrorInfo +{ +public: + TwoStringErrorInfo(ErrCode nUserID, const OUString & rTheArg1, + const OUString & rTheArg2, DialogMask nMask): + DynamicErrorInfo(nUserID, nMask), aArg1(rTheArg1), aArg2(rTheArg2) {} + + const OUString& GetArg1() const { return aArg1; } + const OUString& GetArg2() const { return aArg2; } + +private: + OUString aArg1; + OUString aArg2; + +}; + +struct ImplErrorContext; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC ErrorContext +{ + friend class ErrorHandler; + +public: + ErrorContext(weld::Window *pWin); + virtual ~ErrorContext(); + + virtual bool GetString(ErrCode nErrId, OUString& rCtxStr) = 0; + weld::Window* GetParent(); + + static ErrorContext* GetContext(); + +private: + std::unique_ptr<ImplErrorContext> pImpl; + +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx new file mode 100644 index 000000000..88cd3018b --- /dev/null +++ b/include/vcl/event.hxx @@ -0,0 +1,382 @@ +/* -*- 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_EVENT_HXX +#define INCLUDED_VCL_EVENT_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/keycod.hxx> +#include <vcl/settings.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/outdev.hxx> +#include <vcl/window.hxx> +#include <optional> + +class CommandEvent; + +enum class TextDirectionality { + LeftToRight_TopToBottom, + RightToLeft_TopToBottom, + TopToBottom_RightToLeft, + BottomToTop_LeftToRight +}; + +class VCL_DLLPUBLIC KeyEvent +{ +private: + vcl::KeyCode maKeyCode; + sal_uInt16 mnRepeat; + sal_Unicode mnCharCode; + +public: + KeyEvent(); + KeyEvent( sal_Unicode nChar, const vcl::KeyCode& rKeyCode, + sal_uInt16 nRepeat = 0 ); + + sal_Unicode GetCharCode() const { return mnCharCode; } + const vcl::KeyCode& GetKeyCode() const { return maKeyCode; } + sal_uInt16 GetRepeat() const { return mnRepeat; } + + KeyEvent LogicalTextDirectionality (TextDirectionality eMode) const; +}; + +inline KeyEvent::KeyEvent() +{ + mnCharCode = 0; + mnRepeat = 0; +} + +inline KeyEvent::KeyEvent( sal_Unicode nChar, const vcl::KeyCode& rKeyCode, + sal_uInt16 nRepeat ) : + maKeyCode( rKeyCode ) + +{ + mnCharCode = nChar; + mnRepeat = nRepeat; +} + + +enum class MouseEventModifiers +{ + NONE = 0, + // mouse move modifiers + SIMPLEMOVE = 0x0001, + DRAGMOVE = 0x0002, + DRAGCOPY = 0x0004, + ENTERWINDOW = 0x0010, + LEAVEWINDOW = 0x0020, + SYNTHETIC = 0x0040, + MODIFIERCHANGED = 0x0080, + // mouse up/down-button modifiers + SIMPLECLICK = 0x0100, + SELECT = 0x0200, + MULTISELECT = 0x0400, + RANGESELECT = 0x0800 +}; +namespace o3tl +{ + template<> struct typed_flags<MouseEventModifiers> : is_typed_flags<MouseEventModifiers, 0xff7> {}; +} + +// Mouse buttons +#define MOUSE_LEFT (sal_uInt16(0x0001)) +#define MOUSE_MIDDLE (sal_uInt16(0x0002)) +#define MOUSE_RIGHT (sal_uInt16(0x0004)) + +class VCL_DLLPUBLIC MouseEvent +{ +private: + Point maPos; + MouseEventModifiers mnMode; + sal_uInt16 mnClicks; + sal_uInt16 mnCode; + + // Set, if the document relative logic position are available + std::optional<Point> maLogicPosition; + +public: + explicit MouseEvent(); + explicit MouseEvent( const Point& rPos, sal_uInt16 nClicks = 1, + MouseEventModifiers nMode = MouseEventModifiers::NONE, sal_uInt16 nButtons = 0, + sal_uInt16 nModifier = 0 ); + + const Point& GetPosPixel() const { return maPos; } + MouseEventModifiers GetMode() const { return mnMode; } + + sal_uInt16 GetClicks() const { return mnClicks; } + + void setLogicPosition(Point aLogicPosition) + { + maLogicPosition = aLogicPosition; + } + + std::optional<Point> getLogicPosition() const + { + return maLogicPosition; + } + + bool IsEnterWindow() const + { return bool(mnMode & MouseEventModifiers::ENTERWINDOW); } + bool IsLeaveWindow() const + { return bool(mnMode & MouseEventModifiers::LEAVEWINDOW); } + bool IsSynthetic() const + { return bool(mnMode & MouseEventModifiers::SYNTHETIC); } + bool IsModifierChanged() const + { return bool(mnMode & MouseEventModifiers::MODIFIERCHANGED); } + + sal_uInt16 GetButtons() const + { return (mnCode & (MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT)); } + bool IsLeft() const + { return ((mnCode & MOUSE_LEFT) != 0); } + bool IsMiddle() const + { return ((mnCode & MOUSE_MIDDLE) != 0); } + bool IsRight() const + { return ((mnCode & MOUSE_RIGHT) != 0); } + + sal_uInt16 GetModifier() const + { return (mnCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)); } + bool IsShift() const + { return ((mnCode & KEY_SHIFT) != 0); } + bool IsMod1() const + { return ((mnCode & KEY_MOD1) != 0); } + bool IsMod2() const + { return ((mnCode & KEY_MOD2) != 0); } + bool IsMod3() const + { return ((mnCode & KEY_MOD3) != 0); } +}; + +inline MouseEvent::MouseEvent() +{ + mnMode = MouseEventModifiers::NONE; + mnClicks = 0; + mnCode = 0; +} + +inline MouseEvent::MouseEvent( const Point& rPos, sal_uInt16 nClicks, + MouseEventModifiers nMode, + sal_uInt16 nButtons, sal_uInt16 nModifier ) : + maPos( rPos ) +{ + mnClicks = nClicks; + mnMode = nMode; + mnCode = nButtons | nModifier; +} + +enum class HelpEventMode +{ + NONE = 0x0000, + CONTEXT = 0x0001, + BALLOON = 0x0002, + QUICK = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags<HelpEventMode> : is_typed_flags<HelpEventMode, 0x07> {}; +} + +class VCL_DLLPUBLIC HelpEvent +{ +private: + Point maPos; + HelpEventMode mnMode; + bool mbKeyboardActivated; + +public: + explicit HelpEvent( const Point& rMousePos, HelpEventMode nHelpMode ); + + const Point& GetMousePosPixel() const { return maPos; } + HelpEventMode GetMode() const { return mnMode; } + bool KeyboardActivated() const { return mbKeyboardActivated; } + void SetKeyboardActivated( bool bKeyboard ) { mbKeyboardActivated = bKeyboard; } +}; + +inline HelpEvent::HelpEvent( const Point& rMousePos, HelpEventMode nHelpMode ) : + maPos( rMousePos ) +{ + mnMode = nHelpMode; + mbKeyboardActivated = false; +} + +/// Event to pass information for UserDraw() handling eg. in comboboxes. +class VCL_DLLPUBLIC UserDrawEvent +{ +private: + /// Window that owns the user draw. + VclPtr<vcl::Window> mpWindow; + + /// RenderContext to which we should draw - can be a VirtualDevice or anything. + VclPtr<vcl::RenderContext> mpRenderContext; + + tools::Rectangle maOutRect; + sal_uInt16 mnItemId; + bool mbSelected; + +public: + UserDrawEvent(vcl::Window* pWindow, vcl::RenderContext* pRenderContext, + const tools::Rectangle& rOutRect, sal_uInt16 nId, bool bSelected = false) + : mpWindow(pWindow) + , mpRenderContext(pRenderContext) + , maOutRect( rOutRect ) + , mnItemId(nId) + , mbSelected(bSelected) + { + } + + vcl::Window* GetWindow() const { return mpWindow; } + vcl::RenderContext* GetRenderContext() const { return mpRenderContext; } + const tools::Rectangle& GetRect() const { return maOutRect; } + sal_uInt16 GetItemId() const { return mnItemId; } + bool IsSelected() const { return mbSelected; } +}; + +class VCL_DLLPUBLIC TrackingEvent +{ +private: + MouseEvent maMEvt; + TrackingEventFlags mnFlags; + +public: + explicit TrackingEvent( const MouseEvent&, + TrackingEventFlags nTrackFlags = TrackingEventFlags::NONE ); + + const MouseEvent& GetMouseEvent() const { return maMEvt; } + + bool IsTrackingRepeat() const + { return bool(mnFlags & TrackingEventFlags::Repeat); } + bool IsTrackingEnded() const + { return bool(mnFlags & TrackingEventFlags::End); } + bool IsTrackingCanceled() const + { return bool(mnFlags & TrackingEventFlags::Cancel); } +}; + +inline TrackingEvent::TrackingEvent( const MouseEvent& rMEvt, + TrackingEventFlags nTrackFlags ) : + maMEvt( rMEvt ) +{ + mnFlags = nTrackFlags; +} + + +enum class MouseNotifyEvent +{ + NONE = 0, + MOUSEBUTTONDOWN = 1, + MOUSEBUTTONUP = 2, + MOUSEMOVE = 3, + KEYINPUT = 4, + KEYUP = 5, + GETFOCUS = 6, + LOSEFOCUS = 7, + COMMAND = 8, + INPUTENABLE = 10 +}; + +class VCL_DLLPUBLIC NotifyEvent +{ +private: + VclPtr<vcl::Window> mpWindow; + void* mpData; + MouseNotifyEvent mnEventType; + +public: + NotifyEvent( MouseNotifyEvent nEventType, + vcl::Window* pWindow, + const void* pEvent = nullptr ); + + MouseNotifyEvent GetType() const { return mnEventType; } + vcl::Window* GetWindow() const { return mpWindow; } + void* GetData() const { return mpData; } + const KeyEvent* GetKeyEvent() const; + const MouseEvent* GetMouseEvent() const; + const CommandEvent* GetCommandEvent() const; +}; + +inline const KeyEvent* NotifyEvent::GetKeyEvent() const +{ + if ( (mnEventType == MouseNotifyEvent::KEYINPUT) || (mnEventType == MouseNotifyEvent::KEYUP) ) + return static_cast<const KeyEvent*>(mpData); + else + return nullptr; +} + +inline const MouseEvent* NotifyEvent::GetMouseEvent() const +{ + if ( (mnEventType >= MouseNotifyEvent::MOUSEBUTTONDOWN) && (mnEventType <= MouseNotifyEvent::MOUSEMOVE) ) + return static_cast<const MouseEvent*>(mpData); + else + return nullptr; +} + +inline const CommandEvent* NotifyEvent::GetCommandEvent() const +{ + if ( mnEventType == MouseNotifyEvent::COMMAND ) + return static_cast<const CommandEvent*>(mpData); + else + return nullptr; +} + + +enum class DataChangedEventType { + NONE = 0, + SETTINGS = 1, + DISPLAY = 2, + FONTS = 4, + PRINTER = 5, + FONTSUBSTITUTION = 6 +}; + +class VCL_DLLPUBLIC DataChangedEvent +{ +private: + void* mpData; + AllSettingsFlags mnFlags; + DataChangedEventType mnType; + +public: + explicit DataChangedEvent( DataChangedEventType nType, + const void* pData = nullptr, + AllSettingsFlags nFlags = AllSettingsFlags::NONE ); + + DataChangedEventType GetType() const { return mnType; } + AllSettingsFlags GetFlags() const { return mnFlags; } + + const AllSettings* GetOldSettings() const; +}; + +inline DataChangedEvent::DataChangedEvent( DataChangedEventType nType, + const void* pData, + AllSettingsFlags nChangeFlags ) +{ + mpData = const_cast<void*>(pData); + mnFlags = nChangeFlags; + mnType = nType; +} + +inline const AllSettings* DataChangedEvent::GetOldSettings() const +{ + if ( mnType == DataChangedEventType::SETTINGS ) + return static_cast<const AllSettings*>(mpData); + else + return nullptr; +} + +#endif // INCLUDED_VCL_EVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/evntpost.hxx b/include/vcl/evntpost.hxx new file mode 100644 index 000000000..ca6be18a6 --- /dev/null +++ b/include/vcl/evntpost.hxx @@ -0,0 +1,46 @@ +/* -*- 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_EVNTPOST_HXX +#define INCLUDED_VCL_EVNTPOST_HXX + +#include <config_options.h> +#include <tools/link.hxx> +#include <vcl/dllapi.h> + +struct ImplSVEvent; + +namespace vcl +{ + class UNLESS_MERGELIBS(VCL_DLLPUBLIC) EventPoster + { + ImplSVEvent * m_nId; + Link<LinkParamNone*,void> m_aLink; + + DECL_DLLPRIVATE_LINK( DoEvent_Impl, void*, void ); + + public: + EventPoster( const Link<LinkParamNone*,void>& rLink ); + ~EventPoster(); + void Post(); + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/exceptiontypes.hxx b/include/vcl/exceptiontypes.hxx new file mode 100644 index 000000000..bde3f5f5f --- /dev/null +++ b/include/vcl/exceptiontypes.hxx @@ -0,0 +1,29 @@ +/* -*- 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_EXCEPTIONTYPES_HXX +#define INCLUDED_VCL_EXCEPTIONTYPES_HXX + +enum class ExceptionCategory { + NONE, ResourceNotLoaded, System, UserInterface +}; + +#endif // INCLUDED_VCL_EXCEPTIONTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/extoutdevdata.hxx b/include/vcl/extoutdevdata.hxx new file mode 100644 index 000000000..5db49cddb --- /dev/null +++ b/include/vcl/extoutdevdata.hxx @@ -0,0 +1,39 @@ +/* -*- 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_EXTOUTDEVDATA_HXX +#define INCLUDED_VCL_EXTOUTDEVDATA_HXX + +#include <vcl/dllapi.h> + +namespace vcl +{ + +class VCL_DLLPUBLIC ExtOutDevData +{ +public: + + virtual ~ExtOutDevData(); +}; + +} + +#endif // INCLUDED_VCL_EXTOUTDEVDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx new file mode 100644 index 000000000..24a6eab79 --- /dev/null +++ b/include/vcl/field.hxx @@ -0,0 +1,435 @@ +/* -*- 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_FIELD_HXX +#define INCLUDED_VCL_FIELD_HXX + +#include <config_options.h> +#include <memory> +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <tools/date.hxx> +#include <tools/time.hxx> +#include <vcl/spinfld.hxx> +#include <tools/fldunit.hxx> + +namespace com::sun::star::lang { struct Locale; } + +class CalendarWrapper; +class LocaleDataWrapper; +class LanguageTag; + + +class VCL_DLLPUBLIC FormatterBase +{ +private: + VclPtr<Edit> mpField; + std::unique_ptr<LocaleDataWrapper> + mpLocaleDataWrapper; + bool mbReformat; + bool mbStrictFormat; + bool mbEmptyFieldValue; + bool mbEmptyFieldValueEnabled; + +protected: + SAL_DLLPRIVATE void ImplSetText( const OUString& rText, Selection const * pNewSel = nullptr ); + SAL_DLLPRIVATE bool ImplGetEmptyFieldValue() const { return mbEmptyFieldValue; } + + void SetEmptyFieldValueData( bool bValue ) { mbEmptyFieldValue = bValue; } + + SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const; + + Edit* GetField() const { return mpField; } + void ClearField() { mpField.clear(); } + +public: + explicit FormatterBase(Edit* pField); + virtual ~FormatterBase(); + + const LocaleDataWrapper& GetLocaleDataWrapper() const; + + bool MustBeReformatted() const { return mbReformat; } + void MarkToBeReformatted( bool b ) { mbReformat = b; } + + void SetStrictFormat( bool bStrict ); + bool IsStrictFormat() const { return mbStrictFormat; } + + virtual void Reformat(); + virtual void ReformatAll(); + + const css::lang::Locale& GetLocale() const; + const LanguageTag& GetLanguageTag() const; + + void SetEmptyFieldValue(); + bool IsEmptyFieldValue() const; + + void EnableEmptyFieldValue( bool bEnable ) { mbEmptyFieldValueEnabled = bEnable; } + bool IsEmptyFieldValueEnabled() const { return mbEmptyFieldValueEnabled; } +}; + +#define PATTERN_FORMAT_EMPTYLITERALS (sal_uInt16(0x0001)) + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) PatternFormatter : public FormatterBase +{ +private: + OString m_aEditMask; + OUString maLiteralMask; + bool mbSameMask; + bool mbInPattKeyInput; + +protected: + PatternFormatter(Edit* pEdit); + + SAL_DLLPRIVATE void ImplSetMask(const OString& rEditMask, + const OUString& rLiteralMask); + SAL_DLLPRIVATE bool ImplIsSameMask() const { return mbSameMask; } + SAL_DLLPRIVATE bool& ImplGetInPattKeyInput() { return mbInPattKeyInput; } + +public: + virtual ~PatternFormatter() override; + + virtual void Reformat() override; + + void SetMask(const OString& rEditMask, const OUString& rLiteralMask ); + const OString& GetEditMask() const { return m_aEditMask; } + const OUString& GetLiteralMask() const { return maLiteralMask; } + + void SetString( const OUString& rStr ); + OUString GetString() const; +}; + + +class VCL_DLLPUBLIC NumericFormatter : public FormatterBase +{ +public: + virtual ~NumericFormatter() override; + + virtual void Reformat() override; + + void SetMin( sal_Int64 nNewMin ); + sal_Int64 GetMin() const { return mnMin; } + void SetMax( sal_Int64 nNewMax ); + sal_Int64 GetMax() const { return mnMax; } + + sal_Int64 ClipAgainstMinMax(sal_Int64 nValue) const; + + void SetFirst( sal_Int64 nNewFirst ) { mnFirst = nNewFirst; } + sal_Int64 GetFirst() const { return mnFirst; } + void SetLast( sal_Int64 nNewLast ) { mnLast = nNewLast; } + sal_Int64 GetLast() const { return mnLast; } + void SetSpinSize( sal_Int64 nNewSize ) { mnSpinSize = nNewSize; } + sal_Int64 GetSpinSize() const { return mnSpinSize; } + + void SetDecimalDigits( sal_uInt16 nDigits ); + sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits;} + + void SetUseThousandSep( bool b ); + bool IsUseThousandSep() const { return mbThousandSep; } + + void SetUserValue( sal_Int64 nNewValue ); + virtual void SetValue( sal_Int64 nNewValue ); + sal_Int64 GetValue() const; + virtual OUString CreateFieldText( sal_Int64 nValue ) const; + + sal_Int64 Normalize( sal_Int64 nValue ) const; + sal_Int64 Denormalize( sal_Int64 nValue ) const; + + OUString GetValueString() const; + void SetValueFromString(const OUString& rStr); + +protected: + sal_Int64 mnLastValue; + sal_Int64 mnMin; + sal_Int64 mnMax; + bool mbWrapOnLimits; + bool mbFormatting; + + // the members below are used in all derivatives of NumericFormatter + // not in NumericFormatter itself. + sal_Int64 mnSpinSize; + sal_Int64 mnFirst; + sal_Int64 mnLast; + + NumericFormatter(Edit* pEdit); + + void FieldUp(); + void FieldDown(); + void FieldFirst(); + void FieldLast(); + void FormatValue(Selection const * pNewSelection = nullptr); + + SAL_DLLPRIVATE void ImplNumericReformat(); + SAL_DLLPRIVATE void ImplNewFieldValue( sal_Int64 nNewValue ); + SAL_DLLPRIVATE void ImplSetUserValue( sal_Int64 nNewValue, Selection const * pNewSelection = nullptr ); + + virtual sal_Int64 GetValueFromString(const OUString& rStr) const; + +private: + sal_uInt16 mnDecimalDigits; + bool mbThousandSep; + +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DateFormatter : public FormatterBase +{ +private: + std::unique_ptr<CalendarWrapper> mxCalendarWrapper; + Date maFieldDate; + Date maLastDate; + Date maMin; + Date maMax; + bool mbLongFormat; + bool mbShowDateCentury; + ExtDateFieldFormat mnExtDateFormat; + bool mbEnforceValidValue; + +protected: + DateFormatter(Edit* pEdit); + + SAL_DLLPRIVATE const Date& ImplGetFieldDate() const { return maFieldDate; } + SAL_DLLPRIVATE void ImplDateReformat( const OUString& rStr, OUString& rOutStr ); + SAL_DLLPRIVATE void ImplSetUserDate( const Date& rNewDate, + Selection const * pNewSelection = nullptr ); + SAL_DLLPRIVATE OUString ImplGetDateAsText( const Date& rDate ) const; + SAL_DLLPRIVATE void ImplNewFieldValue( const Date& rDate ); + CalendarWrapper& GetCalendarWrapper() const; + + SAL_DLLPRIVATE bool ImplAllowMalformedInput() const; + +public: + virtual ~DateFormatter() override; + + virtual void Reformat() override; + virtual void ReformatAll() override; + + void SetExtDateFormat( ExtDateFieldFormat eFormat ); + ExtDateFieldFormat GetExtDateFormat( bool bResolveSystemFormat = false ) const; + + void SetMin( const Date& rNewMin ); + const Date& GetMin() const { return maMin; } + + void SetMax( const Date& rNewMax ); + const Date& GetMax() const { return maMax; } + + + // MT: Remove these methods too, ExtDateFormat should be enough! + // What should happen if using DDMMYYYY, but ShowCentury=false? + + void SetLongFormat( bool bLong ); + bool IsLongFormat() const { return mbLongFormat; } + void SetShowDateCentury( bool bShowCentury ); + bool IsShowDateCentury() const { return mbShowDateCentury; } + + + void SetDate( const Date& rNewDate ); + Date GetDate() const; + void SetEmptyDate(); + bool IsEmptyDate() const; + + void ResetLastDate() { maLastDate = Date( Date::EMPTY ); } + + static void ExpandCentury( Date& rDate ); + static void ExpandCentury( Date& rDate, sal_uInt16 nTwoDigitYearStart ); + + /** enables or disables the enforcement of valid values + + If this is set to true (which is the default), then GetDate will always return a valid + date, no matter whether the current text can really be interpreted as date. (Note: this + is the compatible behavior). + + If this is set to false, the GetDate will return GetInvalidDate, in case the current text + cannot be interpreted as date. + + In addition, if this is set to false, the text in the field will \em not be corrected + when the control loses the focus - instead, the invalid input will be preserved. + */ + void EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; } + bool IsEnforceValidValue( ) const { return mbEnforceValidValue; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TimeFormatter : public FormatterBase +{ +private: + tools::Time maLastTime; + tools::Time maMin; + tools::Time maMax; + TimeFieldFormat meFormat; + TimeFormat mnTimeFormat; + bool mbDuration; + bool mbEnforceValidValue; + +protected: + tools::Time maFieldTime; + + TimeFormatter(Edit* pEdit); + + SAL_DLLPRIVATE void ImplTimeReformat( const OUString& rStr, OUString& rOutStr ); + SAL_DLLPRIVATE void ImplNewFieldValue( const tools::Time& rTime ); + SAL_DLLPRIVATE void ImplSetUserTime( const tools::Time& rNewTime, Selection const * pNewSelection = nullptr ); + SAL_DLLPRIVATE bool ImplAllowMalformedInput() const; + +public: + static OUString FormatTime(const tools::Time& rNewTime, TimeFieldFormat eFormat, TimeFormat eHourFormat, bool bDuration, const LocaleDataWrapper& rLocaleData); + static bool TextToTime(const OUString& rStr, tools::Time& rTime, TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters = true); + static int GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor, + const LocaleDataWrapper& rLocaleDataWrapper); + static tools::Time SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat, + bool bDuration, const OUString& rText, int nCursor, + const LocaleDataWrapper& rLocaleDataWrapper); + + virtual ~TimeFormatter() override; + + virtual void Reformat() override; + virtual void ReformatAll() override; + + void SetMin( const tools::Time& rNewMin ); + const tools::Time& GetMin() const { return maMin; } + void SetMax( const tools::Time& rNewMax ); + const tools::Time& GetMax() const { return maMax; } + + void SetTimeFormat( TimeFormat eNewFormat ); + TimeFormat GetTimeFormat() const { return mnTimeFormat;} + + void SetFormat( TimeFieldFormat eNewFormat ); + TimeFieldFormat GetFormat() const { return meFormat; } + + void SetDuration( bool mbDuration ); + bool IsDuration() const { return mbDuration; } + + void SetTime( const tools::Time& rNewTime ); + void SetUserTime( const tools::Time& rNewTime ); + tools::Time GetTime() const; + void SetEmptyTime() { FormatterBase::SetEmptyFieldValue(); } + bool IsEmptyTime() const { return FormatterBase::IsEmptyFieldValue(); } + + /** enables or disables the enforcement of valid values + + If this is set to true (which is the default), then GetTime will always return a valid + time, no matter whether the current text can really be interpreted as time. (Note: this + is the compatible behavior). + + If this is set to false, the GetTime will return GetInvalidTime, in case the current text + cannot be interpreted as time. + + In addition, if this is set to false, the text in the field will <em>not</em> be corrected + when the control loses the focus - instead, the invalid input will be preserved. + */ + void EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; } + bool IsEnforceValidValue( ) const { return mbEnforceValidValue; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) PatternField final : public SpinField, public PatternFormatter +{ +public: + explicit PatternField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void Modify() override; + virtual void dispose() override; +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) NumericField : public SpinField, public NumericFormatter +{ +public: + explicit NumericField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual Size CalcMinimumSize() const override; + + virtual void Modify() override; + + virtual void Up() override; + virtual void Down() override; + virtual void First() override; + virtual void Last() override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual void dispose() override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DateField : public SpinField, public DateFormatter +{ +private: + Date maFirst; + Date maLast; + +protected: + SAL_DLLPRIVATE void ImplDateSpinArea( bool bUp ); + +public: + explicit DateField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void Up() override; + virtual void Down() override; + virtual void First() override; + virtual void Last() override; + + void SetFirst( const Date& rNewFirst ) { maFirst = rNewFirst; } + const Date& GetFirst() const { return maFirst; } + void SetLast( const Date& rNewLast ) { maLast = rNewLast; } + const Date& GetLast() const { return maLast; } + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TimeField final : public SpinField, public TimeFormatter +{ +private: + tools::Time maFirst; + tools::Time maLast; + + SAL_DLLPRIVATE void ImplTimeSpinArea( bool bUp ); + +public: + explicit TimeField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void Up() override; + virtual void Down() override; + virtual void First() override; + virtual void Last() override; + + void SetFirst( const tools::Time& rNewFirst ) { maFirst = rNewFirst; } + const tools::Time& GetFirst() const { return maFirst; } + void SetLast( const tools::Time& rNewLast ) { maLast = rNewLast; } + const tools::Time& GetLast() const { return maLast; } + + void SetExtFormat( ExtTimeFieldFormat eFormat ); + virtual void dispose() override; +}; + +#endif // INCLUDED_VCL_FIELD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fieldvalues.hxx b/include/vcl/fieldvalues.hxx new file mode 100644 index 000000000..e8f78bd5e --- /dev/null +++ b/include/vcl/fieldvalues.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_FIELDVALUES_HXX +#define INCLUDED_VCL_FIELDVALUES_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <tools/fldunit.hxx> +#include <tools/mapunit.hxx> + +class LocaleDataWrapper; + +namespace vcl +{ +VCL_DLLPUBLIC FieldUnit StringToMetric(const OUString& rMetricString); +VCL_DLLPUBLIC bool TextToValue(const OUString& rStr, double& rValue, sal_Int64 nBaseValue, + sal_uInt16 nDecDigits, const LocaleDataWrapper& rLocaleDataWrapper, + FieldUnit eUnit); + +VCL_DLLPUBLIC sal_Int64 ConvertValue(sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit); +VCL_DLLPUBLIC sal_Int64 ConvertValue(sal_Int64 nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit); + +// for backwards compatibility +// caution: conversion to double loses precision +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit); +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, + MapUnit eOutUnit); +VCL_DLLPUBLIC double ConvertDoubleValue(double nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit); + +// for backwards compatibility +// caution: conversion to double loses precision +inline double ConvertDoubleValue(sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits, + FieldUnit eInUnit, FieldUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, + eOutUnit); +} + +inline double ConvertDoubleValue(sal_Int64 nValue, sal_uInt16 nDecDigits, FieldUnit eInUnit, + MapUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit); +} + +inline double ConvertDoubleValue(sal_Int64 nValue, sal_uInt16 nDecDigits, MapUnit eInUnit, + FieldUnit eOutUnit) +{ + return ConvertDoubleValue(static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit); +} +} + +#endif // INCLUDED_VCL_FIELDVALUES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx new file mode 100644 index 000000000..2d93710ec --- /dev/null +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -0,0 +1,93 @@ +/* -*- 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/. + * + */ + +#pragma once + +#include <config_features.h> + +#if HAVE_FEATURE_PDFIUM + +#include <memory> +#include <rtl/instance.hxx> +#include <vcl/dllapi.h> +#include <vcl/checksum.hxx> + +#include <fpdf_doc.h> + +namespace vcl::pdf +{ +class PDFiumDocument; + +class VCL_DLLPUBLIC PDFium final +{ +private: + PDFium(const PDFium&) = delete; + PDFium& operator=(const PDFium&) = delete; + +public: + PDFium(); + ~PDFium(); +}; + +class VCL_DLLPUBLIC PDFiumPage final +{ +private: + FPDF_PAGE mpPage; + +private: + PDFiumPage(const PDFiumPage&) = delete; + PDFiumPage& operator=(const PDFiumPage&) = delete; + +public: + PDFiumPage(FPDF_PAGE pPage) + : mpPage(pPage) + { + } + + ~PDFiumPage() + { + if (mpPage) + FPDF_ClosePage(mpPage); + } + + FPDF_PAGE getPointer() { return mpPage; } + + /// Get bitmap checksum of the page, without annotations/commenting. + BitmapChecksum getChecksum(int nMDPPerm); +}; + +class VCL_DLLPUBLIC PDFiumDocument final +{ +private: + FPDF_DOCUMENT mpPdfDocument; + +private: + PDFiumDocument(const PDFiumDocument&) = delete; + PDFiumDocument& operator=(const PDFiumDocument&) = delete; + +public: + PDFiumDocument(FPDF_DOCUMENT pPdfDocument); + ~PDFiumDocument(); + + int getPageCount(); + + std::unique_ptr<PDFiumPage> openPage(int nIndex); +}; + +struct PDFiumLibrary : public rtl::StaticWithInit<std::shared_ptr<PDFium>, PDFiumLibrary> +{ + std::shared_ptr<PDFium> operator()() { return std::make_shared<PDFium>(); } +}; + +} // namespace vcl::pdf + +#endif // HAVE_FEATURE_PDFIUM + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/filter/PngImageReader.hxx b/include/vcl/filter/PngImageReader.hxx new file mode 100644 index 000000000..97b261688 --- /dev/null +++ b/include/vcl/filter/PngImageReader.hxx @@ -0,0 +1,43 @@ +/* -*- 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_FILTER_PNGIMAGEREADER_HXX +#define INCLUDED_VCL_FILTER_PNGIMAGEREADER_HXX + +#include <vcl/dllapi.h> + +#include <com/sun/star/uno/Reference.hxx> + +namespace com::sun::star::task +{ +class XStatusIndicator; +} + +class BitmapEx; +class SvStream; + +namespace vcl +{ +class VCL_DLLPUBLIC PngImageReader +{ + SvStream& mrStream; + css::uno::Reference<css::task::XStatusIndicator> mxStatusIndicator; + +public: + PngImageReader(SvStream& rStream); + + bool read(BitmapEx& rBitmap); +}; + +} // namespace vcl + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/filter/pdfdocument.hxx b/include/vcl/filter/pdfdocument.hxx new file mode 100644 index 000000000..ff52aa98d --- /dev/null +++ b/include/vcl/filter/pdfdocument.hxx @@ -0,0 +1,424 @@ +/* -*- 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_FILTER_PDFDOCUMENT_HXX +#define INCLUDED_VCL_FILTER_PDFDOCUMENT_HXX + +#include <memory> +#include <map> +#include <vector> + +#include <tools/stream.hxx> + +#include <vcl/dllapi.h> + +namespace com::sun::star::security +{ +class XCertificate; +} + +namespace com::sun::star::uno +{ +template <class interface_type> class Reference; +} + +namespace vcl::filter +{ +class PDFTrailerElement; +class PDFReferenceElement; +class PDFDocument; +class PDFDictionaryElement; +class PDFArrayElement; +class PDFStreamElement; +class PDFNumberElement; + +/// A byte range in a PDF file. +class VCL_DLLPUBLIC PDFElement +{ + bool m_bVisiting = false; + bool m_bParsing = false; + +public: + PDFElement() = default; + virtual bool Read(SvStream& rStream) = 0; + virtual ~PDFElement() = default; + void setVisiting(bool bVisiting) { m_bVisiting = bVisiting; } + bool alreadyVisiting() const { return m_bVisiting; } + void setParsing(bool bParsing) { m_bParsing = bParsing; } + bool alreadyParsing() const { return m_bParsing; } +}; + +/// Indirect object: something with a unique ID. +class VCL_DLLPUBLIC PDFObjectElement final : public PDFElement +{ + /// The document owning this element. + PDFDocument& m_rDoc; + double m_fObjectValue; + double m_fGenerationValue; + std::map<OString, PDFElement*> m_aDictionary; + /// If set, the object contains this number element (outside any dictionary/array). + PDFNumberElement* m_pNumberElement; + /// Position after the '<<' token. + sal_uInt64 m_nDictionaryOffset; + /// Length of the dictionary buffer till (before) the '>>' token. + sal_uInt64 m_nDictionaryLength; + PDFDictionaryElement* m_pDictionaryElement; + /// Position after the '[' token, if m_pArrayElement is set. + sal_uInt64 m_nArrayOffset; + /// Length of the array buffer till (before) the ']' token. + sal_uInt64 m_nArrayLength; + /// The contained direct array, if any. + PDFArrayElement* m_pArrayElement; + /// The stream of this object, used when this is an object stream. + PDFStreamElement* m_pStreamElement; + /// Objects of an object stream. + std::vector<std::unique_ptr<PDFObjectElement>> m_aStoredElements; + /// Elements of an object in an object stream. + std::vector<std::unique_ptr<PDFElement>> m_aElements; + /// Uncompressed buffer of an object in an object stream. + std::unique_ptr<SvMemoryStream> m_pStreamBuffer; + /// List of all reference elements inside this object's dictionary and + /// nested dictionaries. + std::vector<PDFReferenceElement*> m_aDictionaryReferences; + +public: + PDFObjectElement(PDFDocument& rDoc, double fObjectValue, double fGenerationValue); + bool Read(SvStream& rStream) override; + PDFElement* Lookup(const OString& rDictionaryKey); + PDFObjectElement* LookupObject(const OString& rDictionaryKey); + double GetObjectValue() const; + void SetDictionaryOffset(sal_uInt64 nDictionaryOffset); + sal_uInt64 GetDictionaryOffset(); + void SetDictionaryLength(sal_uInt64 nDictionaryLength); + sal_uInt64 GetDictionaryLength(); + PDFDictionaryElement* GetDictionary(); + void SetDictionary(PDFDictionaryElement* pDictionaryElement); + void SetNumberElement(PDFNumberElement* pNumberElement); + PDFNumberElement* GetNumberElement() const; + /// Get access to the parsed key-value items from the object dictionary. + const std::map<OString, PDFElement*>& GetDictionaryItems(); + const std::vector<PDFReferenceElement*>& GetDictionaryReferences() const; + void AddDictionaryReference(PDFReferenceElement* pReference); + void SetArray(PDFArrayElement* pArrayElement); + void SetStream(PDFStreamElement* pStreamElement); + /// Access to the stream of the object, if it has any. + PDFStreamElement* GetStream() const; + void SetArrayOffset(sal_uInt64 nArrayOffset); + sal_uInt64 GetArrayOffset() const; + void SetArrayLength(sal_uInt64 nArrayLength); + sal_uInt64 GetArrayLength() const; + PDFArrayElement* GetArray() const; + /// Parse objects stored in this object stream. + void ParseStoredObjects(); + std::vector<std::unique_ptr<PDFElement>>& GetStoredElements(); + SvMemoryStream* GetStreamBuffer() const; + void SetStreamBuffer(std::unique_ptr<SvMemoryStream>& pStreamBuffer); + PDFDocument& GetDocument(); +}; + +/// Array object: a list. +class VCL_DLLPUBLIC PDFArrayElement : public PDFElement +{ + std::vector<PDFElement*> m_aElements; + /// The object that contains this array. + PDFObjectElement* m_pObject; + +public: + PDFArrayElement(PDFObjectElement* pObject); + bool Read(SvStream& rStream) override; + void PushBack(PDFElement* pElement); + const std::vector<PDFElement*>& GetElements() const; +}; + +/// Reference object: something with a unique ID. +class VCL_DLLPUBLIC PDFReferenceElement : public PDFElement +{ + PDFDocument& m_rDoc; + int m_fObjectValue; + int m_fGenerationValue; + /// Location after the 'R' token. + sal_uInt64 m_nOffset = 0; + /// The element providing the object number. + PDFNumberElement& m_rObject; + +public: + PDFReferenceElement(PDFDocument& rDoc, PDFNumberElement& rObject, + PDFNumberElement const& rGeneration); + bool Read(SvStream& rStream) override; + /// Assuming the reference points to a number object, return its value. + double LookupNumber(SvStream& rStream) const; + /// Lookup referenced object, without assuming anything about its contents. + PDFObjectElement* LookupObject(); + int GetObjectValue() const; + int GetGenerationValue() const; + sal_uInt64 GetOffset() const; + PDFNumberElement& GetObjectElement() const; +}; + +/// Stream object: a byte array with a known length. +class VCL_DLLPUBLIC PDFStreamElement : public PDFElement +{ + size_t m_nLength; + sal_uInt64 m_nOffset; + /// The byte array itself. + SvMemoryStream m_aMemory; + +public: + explicit PDFStreamElement(size_t nLength); + bool Read(SvStream& rStream) override; + sal_uInt64 GetOffset() const; + SvMemoryStream& GetMemory(); +}; + +/// Name object: a key string. +class VCL_DLLPUBLIC PDFNameElement final : public PDFElement +{ + OString m_aValue; + /// Offset after the '/' token. + sal_uInt64 m_nLocation = 0; + +public: + PDFNameElement(); + bool Read(SvStream& rStream) override; + const OString& GetValue() const; + sal_uInt64 GetLocation() const; + static sal_uInt64 GetLength() { return 0; } +}; + +/// Dictionary object: a set key-value pairs. +class VCL_DLLPUBLIC PDFDictionaryElement : public PDFElement +{ + /// Key-value pairs when the dictionary is a nested value. + std::map<OString, PDFElement*> m_aItems; + /// Offset after the '<<' token. + sal_uInt64 m_nLocation = 0; + /// Position after the '/' token. + std::map<OString, sal_uInt64> m_aDictionaryKeyOffset; + /// Length of the dictionary key and value, till (before) the next token. + std::map<OString, sal_uInt64> m_aDictionaryKeyValueLength; + +public: + PDFDictionaryElement(); + bool Read(SvStream& rStream) override; + + static size_t Parse(const std::vector<std::unique_ptr<PDFElement>>& rElements, + PDFElement* pThis, std::map<OString, PDFElement*>& rDictionary); + static PDFElement* Lookup(const std::map<OString, PDFElement*>& rDictionary, + const OString& rKey); + void SetKeyOffset(const OString& rKey, sal_uInt64 nOffset); + sal_uInt64 GetKeyOffset(const OString& rKey) const; + void SetKeyValueLength(const OString& rKey, sal_uInt64 nLength); + sal_uInt64 GetKeyValueLength(const OString& rKey) const; + const std::map<OString, PDFElement*>& GetItems() const; + /// Looks up an object which is only referenced in this dictionary. + PDFObjectElement* LookupObject(const OString& rDictionaryKey); + /// Looks up an element which is contained in this dictionary. + PDFElement* LookupElement(const OString& rDictionaryKey); +}; + +enum class TokenizeMode +{ + /// Full file. + END_OF_STREAM, + /// Till the first %%EOF token. + EOF_TOKEN, + /// Till the end of the current object. + END_OF_OBJECT, + /// Same as END_OF_OBJECT, but for object streams (no endobj keyword). + STORED_OBJECT +}; + +/// The type column of an entry in a cross-reference stream. +enum class XRefEntryType +{ + /// xref "f" or xref stream "0". + FREE, + /// xref "n" or xref stream "1". + NOT_COMPRESSED, + /// xref stream "2". + COMPRESSED +}; + +/// An entry in a cross-reference stream. +class XRefEntry +{ + XRefEntryType m_eType = XRefEntryType::NOT_COMPRESSED; + /** + * Non-compressed: The byte offset of the object, starting from the + * beginning of the file. + * Compressed: The object number of the object stream in which this object is + * stored. + */ + sal_uInt64 m_nOffset = 0; + /// Are changed as part of an incremental update?. + bool m_bDirty = false; + +public: + XRefEntry(); + + void SetType(XRefEntryType eType) { m_eType = eType; } + + XRefEntryType GetType() const { return m_eType; } + + void SetOffset(sal_uInt64 nOffset) { m_nOffset = nOffset; } + + sal_uInt64 GetOffset() const { return m_nOffset; } + + void SetDirty(bool bDirty) { m_bDirty = bDirty; } + + bool GetDirty() const { return m_bDirty; } +}; + +/// Hex string: in <AABB> form. +class VCL_DLLPUBLIC PDFHexStringElement final : public PDFElement +{ + OString m_aValue; + +public: + bool Read(SvStream& rStream) override; + const OString& GetValue() const; +}; + +/// Literal string: in (asdf) form. +class VCL_DLLPUBLIC PDFLiteralStringElement final : public PDFElement +{ + OString m_aValue; + +public: + bool Read(SvStream& rStream) override; + const OString& GetValue() const; +}; + +/// Numbering object: an integer or a real. +class VCL_DLLPUBLIC PDFNumberElement : public PDFElement +{ + /// Input file start location. + sal_uInt64 m_nOffset = 0; + /// Input file token length. + sal_uInt64 m_nLength = 0; + double m_fValue = 0; + +public: + PDFNumberElement(); + bool Read(SvStream& rStream) override; + double GetValue() const; + sal_uInt64 GetLocation() const; + sal_uInt64 GetLength() const; +}; + +/** + * In-memory representation of an on-disk PDF document. + * + * The PDF element list is not meant to be saved back to disk, but some + * elements remember their source offset / length, and based on that it's + * possible to modify the input file. + */ +class VCL_DLLPUBLIC PDFDocument +{ + /// This vector owns all elements. + std::vector<std::unique_ptr<PDFElement>> m_aElements; + /// Object ID <-> object offset map. + std::map<size_t, XRefEntry> m_aXRef; + /// Object offset <-> Object pointer map. + std::map<size_t, PDFObjectElement*> m_aOffsetObjects; + /// Object ID <-> Object pointer map. + std::map<size_t, PDFObjectElement*> m_aIDObjects; + /// List of xref offsets we know. + std::vector<size_t> m_aStartXRefs; + /// Offsets of trailers, from latest to oldest. + std::vector<size_t> m_aTrailerOffsets; + /// Trailer offset <-> Trailer pointer map. + std::map<size_t, PDFTrailerElement*> m_aOffsetTrailers; + /// List of EOF offsets we know. + std::vector<size_t> m_aEOFs; + PDFTrailerElement* m_pTrailer = nullptr; + /// When m_pTrailer is nullptr, this can still have a dictionary. + PDFObjectElement* m_pXRefStream = nullptr; + /// All editing takes place in this buffer, if it happens. + SvMemoryStream m_aEditBuffer; + + /// Suggest a minimal, yet free signature ID to use for the next signature. + sal_uInt32 GetNextSignature(); + /// Write the signature object as part of signing. + sal_Int32 WriteSignatureObject(const OUString& rDescription, bool bAdES, + sal_uInt64& rLastByteRangeOffset, sal_Int64& rContentOffset); + /// Write the appearance object as part of signing. + sal_Int32 WriteAppearanceObject(); + /// Write the annot object as part of signing. + sal_Int32 WriteAnnotObject(PDFObjectElement const& rFirstPage, sal_Int32 nSignatureId, + sal_Int32 nAppearanceId); + /// Write the updated Page object as part of signing. + bool WritePageObject(PDFObjectElement& rFirstPage, sal_Int32 nAnnotId); + /// Write the updated Catalog object as part of signing. + bool WriteCatalogObject(sal_Int32 nAnnotId, PDFReferenceElement*& pRoot); + /// Write the updated cross-references as part of signing. + void WriteXRef(sal_uInt64 nXRefOffset, PDFReferenceElement const* pRoot); + +public: + PDFDocument(); + PDFDocument& operator=(const PDFDocument&) = delete; + PDFDocument(const PDFDocument&) = delete; + /// @name Low-level functions, to be used by PDFElement subclasses. + //@{ + /// Decode a hex dump. + static std::vector<unsigned char> DecodeHexString(PDFHexStringElement const* pElement); + static OString ReadKeyword(SvStream& rStream); + static size_t FindStartXRef(SvStream& rStream); + void ReadXRef(SvStream& rStream); + void ReadXRefStream(SvStream& rStream); + static void SkipWhitespace(SvStream& rStream); + /// Instead of all whitespace, just skip CR and NL characters. + static void SkipLineBreaks(SvStream& rStream); + size_t GetObjectOffset(size_t nIndex) const; + const std::vector<std::unique_ptr<PDFElement>>& GetElements() const; + std::vector<PDFObjectElement*> GetPages(); + PDFObjectElement* GetCatalog(); + /// Remember the end location of an EOF token. + void PushBackEOF(size_t nOffset); + /// Look up object based on object number, possibly by parsing object streams. + PDFObjectElement* LookupObject(size_t nObjectNumber); + /// Access to the input document, even after the input stream is gone. + SvMemoryStream& GetEditBuffer(); + /// Tokenize elements from current offset. + bool Tokenize(SvStream& rStream, TokenizeMode eMode, + std::vector<std::unique_ptr<PDFElement>>& rElements, + PDFObjectElement* pObjectElement); + /// Register an object (owned directly or indirectly by m_aElements) as a provider for a given ID. + void SetIDObject(size_t nID, PDFObjectElement* pObject); + //@} + + /// @name High-level functions, to be used by others. + //@{ + /// Read elements from the start of the stream till its end. + bool Read(SvStream& rStream); + /// Sign the read document with xCertificate in the edit buffer. + bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate, + const OUString& rDescription, bool bAdES); + /// Serializes the contents of the edit buffer. + bool Write(SvStream& rStream); + /// Get a list of signatures embedded into this document. + std::vector<PDFObjectElement*> GetSignatureWidgets(); + /** + * Get the value of the "modification detection and prevention" permission: + * Valid values are 1, 2 and 3: only 3 allows annotations after signing. + */ + int GetMDPPerm(); + /// Remove the nth signature from read document in the edit buffer. + bool RemoveSignature(size_t nPosition); + /// Get byte offsets of the end of incremental updates. + const std::vector<size_t>& GetEOFs() const; + //@} +}; + +} // namespace vcl::filter + +#endif // INCLUDED_VCL_FILTER_PDFDOCUMENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fixed.hxx b/include/vcl/fixed.hxx new file mode 100644 index 000000000..9c4005559 --- /dev/null +++ b/include/vcl/fixed.hxx @@ -0,0 +1,182 @@ +/* -*- 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_FIXED_HXX +#define INCLUDED_VCL_FIXED_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/edit.hxx> +#include <vcl/image.hxx> + + +class VCL_DLLPUBLIC FixedText : public Control +{ +private: + sal_Int32 m_nMaxWidthChars; + sal_Int32 m_nMinWidthChars; + VclPtr<vcl::Window> m_pMnemonicWindow; + + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags, + const Point& rPos, const Size& rSize, bool bFillLayout = false ) const; +public: + SAL_DLLPRIVATE static DrawTextFlags ImplGetTextStyle( WinBits nWinBits ); +protected: + virtual void FillLayoutData() const override; + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + + virtual vcl::Window* getAccessibleRelationLabelFor() const override; + +public: + explicit FixedText( vcl::Window* pParent, WinBits nStyle = 0 ); + virtual ~FixedText() override; + virtual void dispose() override; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void setMaxWidthChars(sal_Int32 nWidth); + void setMinWidthChars(sal_Int32 nWidth); + static Size CalcMinimumTextSize(Control const* pControl, long nMaxWidth = 0x7fffffff); + static Size getTextDimensions(Control const *pControl, const OUString &rTxt, long nMaxWidth); + Size CalcMinimumSize(long nMaxWidth = 0x7fffffff) const; + virtual Size GetOptimalSize() const override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + void set_mnemonic_widget(vcl::Window *pWindow); + vcl::Window* get_mnemonic_widget() const { return m_pMnemonicWindow; } +}; + +class SelectableFixedText final : public Edit +{ +public: + explicit SelectableFixedText( vcl::Window* pParent, WinBits nStyle ); + + virtual void LoseFocus() override; + virtual void ApplySettings(vcl::RenderContext&) override; +}; + + +class VCL_DLLPUBLIC FixedLine : public Control +{ +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); + +protected: + virtual void FillLayoutData() const override; + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + +public: + explicit FixedLine( vcl::Window* pParent, WinBits nStyle = WB_HORZ ); + + virtual void ApplySettings(vcl::RenderContext&) override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual Size GetOptimalSize() const override; +}; + +class VCL_DLLPUBLIC FixedBitmap final : public Control +{ +private: + BitmapEx maBitmap; + + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, const Point& rPos, const Size& rSize ); + +public: + explicit FixedBitmap( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void ApplySettings(vcl::RenderContext&) override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void SetBitmap( const BitmapEx& rBitmap ); +}; + + +class VCL_DLLPUBLIC FixedImage : public Control +{ +private: + Image maImage; + +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + +protected: + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, + const Point& rPos, const Size& rSize ); +public: + explicit FixedImage( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void ApplySettings(vcl::RenderContext&) override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual Size GetOptimalSize() const override; + + void SetImage( const Image& rImage ); + const Image& GetImage() const { return maImage; } + + void SetModeImage( const Image& rImage ); + const Image& GetModeImage( ) const { return maImage;} + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + static Image loadThemeImage(const OUString &rFileName); +}; + +#endif // INCLUDED_VCL_FIXED_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/floatwin.hxx b/include/vcl/floatwin.hxx new file mode 100644 index 000000000..91a6ae3c8 --- /dev/null +++ b/include/vcl/floatwin.hxx @@ -0,0 +1,163 @@ +/* -*- 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_FLOATWIN_HXX +#define INCLUDED_VCL_FLOATWIN_HXX + +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> +#include <memory> +#include <o3tl/typed_flags_set.hxx> + +class ToolBox; + + +enum class FloatWinPopupFlags +{ + NONE = 0x000000, + AllowTearOff = 0x000001, + Down = 0x000002, + Up = 0x000004, + Left = 0x000008, + Right = 0x000010, + NoKeyClose = 0x000020, + AllMouseButtonClose = 0x000040, + NoAppFocusClose = 0x000080, + NewLevel = 0x000100, + NoMouseUpClose = 0x000200, + GrabFocus = 0x000400, + NoHorzPlacement = 0x000800, +}; +namespace o3tl +{ + template<> struct typed_flags<FloatWinPopupFlags> : is_typed_flags<FloatWinPopupFlags, 0x0fff> {}; +} + +enum class FloatWinPopupEndFlags +{ + NONE = 0x00, + Cancel = 0x01, + TearOff = 0x02, + DontCallHdl = 0x04, + CloseAll = 0x08, + NoCloseChildren = 0x10, +}; +namespace o3tl +{ + template<> struct typed_flags<FloatWinPopupEndFlags> : is_typed_flags<FloatWinPopupEndFlags, 0x1f> {}; +} + +enum class FloatWinTitleType +{ + Unknown = 0, + Normal = 1, + TearOff = 2, + Popup = 3, + NONE = 4, +}; + +class VCL_DLLPUBLIC FloatingWindow : public SystemWindow +{ + class SAL_DLLPRIVATE ImplData; +private: + VclPtr<FloatingWindow> mpNextFloat; + VclPtr<vcl::Window> mpFirstPopupModeWin; + VclPtr<vcl::Window> mxPrevFocusWin; + std::unique_ptr<ImplData> mpImplData; + tools::Rectangle maFloatRect; + ImplSVEvent * mnPostId; + FloatWinPopupFlags mnPopupModeFlags; + FloatWinTitleType mnTitle; + FloatWinTitleType mnOldTitle; + bool mbInPopupMode; + bool mbPopupMode; + bool mbPopupModeCanceled; + bool mbPopupModeTearOff; + bool mbMouseDown; + bool mbGrabFocus; // act as key input window, although focus is not set + bool mbInCleanUp; + Link<FloatingWindow*,void> maPopupModeEndHdl; + + SAL_DLLPRIVATE void ImplCallPopupModeEnd(); + DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void*, void ); + + FloatingWindow (const FloatingWindow &) = delete; + FloatingWindow & operator= (const FloatingWindow &) = delete; + +protected: + SAL_DLLPRIVATE void ImplInitFloating( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, bool& rbHitTestInsideRect ); + SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat(); + SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow( const vcl::Window* pWindow ); + SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = true; } + SAL_DLLPRIVATE bool ImplIsMouseDown() const { return mbMouseDown; } + static Point ImplCalcPos(vcl::Window* pWindow, + const tools::Rectangle& rRect, FloatWinPopupFlags nFlags, + sal_uInt16& rArrangeIndex, Point* pLOKTwipsPos = nullptr); + static Point ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos); + static tools::Rectangle ImplConvertToAbsPos(vcl::Window* pReference, const tools::Rectangle& rRect); + SAL_DLLPRIVATE void ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPtr<vcl::Window>& xFocusId ); + SAL_DLLPRIVATE tools::Rectangle& ImplGetItemEdgeClipRect(); + SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; } + virtual void doDeferredInit(WinBits nBits) override; + void PixelInvalidate(const tools::Rectangle* pRectangle) override; + +public: + explicit FloatingWindow(vcl::Window* pParent, WinBits nStyle); + explicit FloatingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>()); + virtual ~FloatingWindow() override; + virtual void dispose() override; + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void PopupModeEnd(); + + void SetTitleType( FloatWinTitleType nTitle ); + FloatWinTitleType GetTitleType() const { return mnTitle; } + + void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags ); + void StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags ); + void EndPopupMode( FloatWinPopupEndFlags nFlags = FloatWinPopupEndFlags::NONE ); + void AddPopupModeWindow( vcl::Window* pWindow ); + FloatWinPopupFlags GetPopupModeFlags() const { return mnPopupModeFlags; } + void SetPopupModeFlags( FloatWinPopupFlags nFlags ) { mnPopupModeFlags = nFlags; } + bool IsInPopupMode() const { return mbPopupMode; } + bool IsInCleanUp() const { return mbInCleanUp; } + bool IsPopupModeCanceled() const { return mbPopupModeCanceled; } + bool IsPopupModeTearOff() const { return mbPopupModeTearOff; } + + void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; } + + bool GrabsFocus() const { return mbGrabFocus; } + bool UpdatePositionData(); + + static Point CalcFloatingPosition( vcl::Window* pWindow, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags, sal_uInt16& rArrangeIndex ); +}; + +#endif // INCLUDED_VCL_FLOATWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fmtfield.hxx b/include/vcl/fmtfield.hxx new file mode 100644 index 000000000..c61aca917 --- /dev/null +++ b/include/vcl/fmtfield.hxx @@ -0,0 +1,313 @@ +/* -*- 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_FMTFIELD_HXX +#define INCLUDED_VCL_FMTFIELD_HXX + +#include <config_options.h> +#include <vcl/spinfld.hxx> +#include <memory> + +class SvNumberFormatter; + +namespace validation { class NumberValidator; } + +enum class FORMAT_CHANGE_TYPE +{ + KEYONLY = 0x00, // only a new key was set + FORMATTER = 0x01, // a new formatter was set, usually implies a change of the key, too + PRECISION = 0x02, // a new precision was set + THOUSANDSSEP = 0x03, // the thousands separator setting changed + CURRENCY_SYMBOL = 0x10, + CURRSYM_POSITION = 0x20, +}; + + +class VCL_DLLPUBLIC FormattedField : public SpinField +{ +private: + // A SvNumberFormatter is very expensive (regarding time and space), it is a Singleton + class StaticFormatter + { + static SvNumberFormatter* s_cFormatter; + static sal_uLong s_nReferences; + public: + StaticFormatter(); + ~StaticFormatter(); + + operator SvNumberFormatter* () { return GetFormatter(); } + UNLESS_MERGELIBS(VCL_DLLPUBLIC) static SvNumberFormatter* GetFormatter(); + }; + +protected: + OUString m_sLastValidText; + // Has nothing to do with the current value. It is the last text, which was valid at input (checked by CheckText, + // not yet through formatter) + Selection m_aLastSelection; + + double m_dMinValue; + double m_dMaxValue; + bool m_bHasMin : 1; + bool m_bHasMax : 1; + + bool m_bWrapOnLimits : 1; + bool m_bStrictFormat : 1; + + bool m_bEnableEmptyField : 1; + bool m_bAutoColor : 1; + bool m_bEnableNaN : 1; + bool m_bDisableRemainderFactor : 1; + enum valueState { valueDirty, valueString, valueDouble }; + valueState m_ValueState; + double m_dCurrentValue; + double m_dDefaultValue; + + sal_uLong m_nFormatKey; + SvNumberFormatter* m_pFormatter; + StaticFormatter m_aStaticFormatter; + + double m_dSpinSize; + double m_dSpinFirst; + double m_dSpinLast; + + // There is a difference, when text formatting is enabled, if LostFocus formats the current String and displays it, + // or if a double is created from the String and then + bool m_bTreatAsNumber; + // And with the following members we can use it for formatted text output as well ... + OUString m_sCurrentTextValue; + OUString m_sDefaultText; + + // The last color from the Formatter at the last output operation (not we would use it, but you can get it) + Color* m_pLastOutputColor; + + bool m_bUseInputStringForFormatting; + +public: + FormattedField(vcl::Window* pParent, WinBits nStyle); + + // Min-/Max-management + bool HasMinValue() const { return m_bHasMin; } + void ClearMinValue() { m_bHasMin = false; } + void SetMinValue(double dMin); + double GetMinValue() const { return m_dMinValue; } + + bool HasMaxValue() const { return m_bHasMax; } + void ClearMaxValue() { m_bHasMax = false; } + void SetMaxValue(double dMax); + double GetMaxValue() const { return m_dMaxValue; } + + // Current value + void SetValue(double dVal); + double GetValue(); + // The default implementation uses a formatter, if available + + void SetTextValue(const OUString& rText); + // The String is transformed to a double (with a formatter) and SetValue is called afterwards + // + void SetValueFromString(const OUString& rStr); + + bool IsEmptyFieldEnabled() const { return m_bEnableEmptyField; } + void EnableEmptyField(bool bEnable); + // If disabled, the value will be reset to the last valid value on leave + + void SetDefaultValue(double dDefault) { m_dDefaultValue = dDefault; m_ValueState = valueDirty; } + // If the current String is invalid, GetValue() returns this value + double GetDefaultValue() const { return m_dDefaultValue; } + + // Settings for the format + sal_uLong GetFormatKey() const { return m_nFormatKey; } + void SetFormatKey(sal_uLong nFormatKey); + + SvNumberFormatter* GetFormatter() const { return m_pFormatter; } + void SetFormatter(SvNumberFormatter* pFormatter, bool bResetFormat = true); + // If bResetFormat is sal_False, the old format is tried to be kept. (expensive, if it is no default format, available in all formatters) + // If sal_True, the new FormatKey is set to zero + + bool GetThousandsSep() const; + void SetThousandsSep(bool _bUseSeparator); + // the is no check if the current format is numeric, so be cautious when calling these functions + + void DisableRemainderFactor(); + + sal_uInt16 GetDecimalDigits() const; + void SetDecimalDigits(sal_uInt16 _nPrecision); + // There is no check if the current format is numeric, so be cautious when calling these functions + + SvNumberFormatter* StandardFormatter() { return m_aStaticFormatter; } + // If no new Formatter is created explicitly, this can be used in SetFormatter... + + OUString GetFormat(LanguageType& eLang) const; + bool SetFormat(const OUString& rFormatString, LanguageType eLang); + // sal_False, if the FormatString could not be set (and very probably is invalid) + // This Object is shared via all instances, so be careful! + + bool IsStrictFormat() const { return m_bStrictFormat; } + void SetStrictFormat(bool bEnable) { m_bStrictFormat = bEnable; } + // Check format during input + + // Spin-Handling + virtual void Up() override; + virtual void Down() override; + // Default Implementation: +/- default spin size to the double value + virtual void First() override; + virtual void Last() override; + // Default Implementation: Current double is set to the first or last value + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + void SetSpinSize(double dStep) { m_dSpinSize = dStep; } + double GetSpinSize() const { return m_dSpinSize; } + + void SetSpinFirst(double dFirst) { m_dSpinFirst = dFirst; } + double GetSpinFirst() const { return m_dSpinFirst; } + + void SetSpinLast(double dLast) { m_dSpinLast = dLast; } + double GetSpinLast() const { return m_dSpinLast; } + + bool TreatingAsNumber() const { return m_bTreatAsNumber; } + void TreatAsNumber(bool bDoSo) { m_bTreatAsNumber = bDoSo; } + + void SetOutputHdl(const Link<Edit&, bool>& rLink) { m_aOutputHdl = rLink; } + void SetInputHdl(const Link<sal_Int64*,TriState>& rLink) { m_aInputHdl = rLink; } +public: + virtual void SetText( const OUString& rStr ) override; + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override; + + //The following methods are interesting, if m_bTreatAsNumber is set to sal_False + //If someone does not care about all the double handling and just wants to print the text formatted. + //(((The text will be formatted, using the Formatter, and then set) + void SetTextFormatted(const OUString& rText); + OUString const & GetTextValue() const; + + void SetDefaultText(const OUString& rDefault) { m_sDefaultText = rDefault; } + const OUString& GetDefaultText() const { return m_sDefaultText; } + + // The last colour from the Formatter's last output operation. Output operations get triggered by: + // SetValue, SetTextValue, SetTextFormatted, also indirectly via SetMin - / -MaxValue + Color* GetLastOutputColor() const { return m_pLastOutputColor; } + + /** reformats the current text. Interesting if the user entered some text in an "input format", and + this should be formatted in the "output format" (which may differ, e.g. by additional numeric + digits or such). + */ + void Commit(); + + // enable automatic coloring. if set to sal_True, and the format the field is working with for any current value + // says that it has to be painted in a special color (e.g. a format where negative numbers should be printed + // red), the text is painted with that color automatically. + // The color used is the same as returned by GetLastOutputColor() + void SetAutoColor(bool _bAutomatic); + + /** enables handling of not-a-number value. + + When this is set to <FALSE/> (the default), then invalid inputs (i.e. text which cannot be + interpreted, according to the current formatting) will be handled as if the default value + has been entered. GetValue the will return this default value. + + When set to <TRUE/>, then GetValue will return NaN (not a number, see <method scope="rtl::math">isNan</method>) + when the current input is invalid. + + Note that setting this to <TRUE/> implies that upon leaving the control, the input + will *not* be corrected to a valid value. For example, if the user enters "foo" in the + control, and then tabs out of it, the text "foo" will persist, and GetValue will + return NaN in subsequent calls. + */ + void EnableNotANumber( bool _bEnable ); + + /** When being set to true, the strings in the field are formatted using the + InputLine format. That's also what you get in Calc when you edit a cell + using F2 + */ + void UseInputStringForFormatting(); + bool IsUsingInputStringForFormatting() const { return m_bUseInputStringForFormatting;} + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + + virtual FactoryFunction GetUITestFactory() const override; + +protected: + virtual bool EventNotify(NotifyEvent& rNEvt) override; + void impl_Modify(bool makeValueDirty = true); + virtual void Modify() override; + + // Override CheckText for input-time checks + virtual bool CheckText(const OUString&) const { return true; } + + // any aspect of the current format has changed + virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat); + + void ImplSetTextImpl(const OUString& rNew, Selection const * pNewSel); + void ImplSetValue(double dValue, bool bForce); + bool ImplGetValue(double& dNewVal); + + void ImplSetFormatKey(sal_uLong nFormatKey); + // SetFormatKey without FormatChanged notification + + SvNumberFormatter* CreateFormatter() { SetFormatter(StandardFormatter()); return m_pFormatter; } + SvNumberFormatter* ImplGetFormatter() const { return m_pFormatter ? m_pFormatter : const_cast<FormattedField*>(this)->CreateFormatter(); } + + bool PreNotify(NotifyEvent& rNEvt) override; + + void ReFormat(); +private: + Link<Edit&, bool> m_aOutputHdl; + Link<sal_Int64*, TriState> m_aInputHdl; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DoubleNumericField final : public FormattedField +{ +public: + DoubleNumericField(vcl::Window* pParent, WinBits nStyle); + + virtual ~DoubleNumericField() override; + +private: + virtual bool CheckText(const OUString& sText) const override; + + virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat) override; + void ResetConformanceTester(); + + std::unique_ptr<validation::NumberValidator> m_pNumberValidator; +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DoubleCurrencyField final : public FormattedField +{ +public: + DoubleCurrencyField(vcl::Window* pParent, WinBits nStyle); + + const OUString& getCurrencySymbol() const { return m_sCurrencySymbol; } + void setCurrencySymbol(const OUString& rSymbol); + + bool getPrependCurrSym() const { return m_bPrependCurrSym; } + void setPrependCurrSym(bool _bPrepend); + +private: + virtual void FormatChanged(FORMAT_CHANGE_TYPE nWhat) override; + + void UpdateCurrencyFormat(); + + OUString m_sCurrencySymbol; + bool m_bPrependCurrSym; + bool m_bChangingFormat; +}; + +#endif // INCLUDED_VCL_FMTFIELD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fntstyle.hxx b/include/vcl/fntstyle.hxx new file mode 100644 index 000000000..03814c262 --- /dev/null +++ b/include/vcl/fntstyle.hxx @@ -0,0 +1,41 @@ +/* -*- 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_FNTSTYLE_HXX +#define INCLUDED_VCL_FNTSTYLE_HXX + +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> + +enum class FontRelief { NONE, Embossed, Engraved, FontRelief_FORCE_EQUAL_SIZE=SAL_MAX_ENUM }; + +enum class FontKerning +{ + NONE = 0x00, + FontSpecific = 0x01, + Asian = 0x02, +}; +namespace o3tl +{ + template<> struct typed_flags<FontKerning> : is_typed_flags<FontKerning, 0x03> {}; +} + +#endif // INCLUDED_VCL_FNTSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/font.hxx b/include/vcl/font.hxx new file mode 100644 index 000000000..faccd0cff --- /dev/null +++ b/include/vcl/font.hxx @@ -0,0 +1,185 @@ +/* -*- 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_FONT_HXX +#define INCLUDED_VCL_FONT_HXX + +#include <rtl/ustring.hxx> +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> +#include <tools/fontenum.hxx> +#include <i18nlangtag/lang.h> +#include <vcl/fntstyle.hxx> +#include <o3tl/cow_wrapper.hxx> + +class Size; +class LanguageTag; +class SvStream; +#define FontAlign TextAlign + +class ImplFont; +class FontAttributes; +namespace vcl { class Font; } +// need to first declare these outside the vcl namespace, or the friend declarations won't work right +VCL_DLLPUBLIC SvStream& ReadFont( SvStream& rIStm, vcl::Font& ); +VCL_DLLPUBLIC SvStream& WriteFont( SvStream& rOStm, const vcl::Font& ); + +namespace vcl { + +class SAL_WARN_UNUSED VCL_DLLPUBLIC Font +{ +public: + explicit Font(); + Font( const Font& ); // TODO make me explicit + Font( Font&& ) noexcept; + explicit Font( const OUString& rFamilyName, const Size& ); + explicit Font( const OUString& rFamilyName, const OUString& rStyleName, const Size& ); + explicit Font( FontFamily eFamily, const Size& ); + virtual ~Font(); + + const OUString& GetFamilyName() const; + FontFamily GetFamilyType(); + FontFamily GetFamilyType() const; + const OUString& GetStyleName() const; + + FontWeight GetWeight(); + FontWeight GetWeight() const; + FontItalic GetItalic(); + FontItalic GetItalic() const; + FontPitch GetPitch(); + FontPitch GetPitch() const; + FontWidth GetWidthType(); + FontWidth GetWidthType() const; + FontAlign GetAlignment() const; + rtl_TextEncoding GetCharSet() const; + + bool IsSymbolFont() const; + + void SetFamilyName( const OUString& rFamilyName ); + void SetStyleName( const OUString& rStyleName ); + void SetFamily( FontFamily ); + + void SetPitch( FontPitch ePitch ); + void SetItalic( FontItalic ); + void SetWeight( FontWeight ); + void SetWidthType( FontWidth ); + void SetAlignment( FontAlign ); + void SetCharSet( rtl_TextEncoding ); + + void SetSymbolFlag( bool ); + + // Device dependent functions + int GetQuality() const; + + void SetQuality(int); + void IncreaseQualityBy(int); + void DecreaseQualityBy(int); + + // setting the color on the font is obsolete, the only remaining + // valid use is for keeping backward compatibility with old MetaFiles + const Color& GetColor() const; + const Color& GetFillColor() const; + + bool IsTransparent() const; + + void SetColor( const Color& ); + void SetFillColor( const Color& ); + + void SetTransparent( bool bTransparent ); + + void SetFontSize( const Size& ); + const Size& GetFontSize() const; + void SetFontHeight( long nHeight ); + long GetFontHeight() const; + void SetAverageFontWidth( long nWidth ); + long GetAverageFontWidth() const; + + // Prefer LanguageTag over LanguageType + void SetLanguageTag( const LanguageTag & ); + const LanguageTag& GetLanguageTag() const; + void SetCJKContextLanguageTag( const LanguageTag& ); + const LanguageTag& GetCJKContextLanguageTag() const; + void SetLanguage( LanguageType ); + LanguageType GetLanguage() const; + void SetCJKContextLanguage( LanguageType ); + LanguageType GetCJKContextLanguage() const; + + void SetOrientation( short nLineOrientation ); + short GetOrientation() const; + void SetVertical( bool bVertical ); + bool IsVertical() const; + void SetKerning( FontKerning nKerning ); + FontKerning GetKerning() const; + bool IsKerning() const; + + void SetOutline( bool bOutline ); + bool IsOutline() const; + void SetShadow( bool bShadow ); + bool IsShadow() const; + void SetRelief( FontRelief ); + FontRelief GetRelief() const; + void SetUnderline( FontLineStyle ); + FontLineStyle GetUnderline() const; + void SetOverline( FontLineStyle ); + FontLineStyle GetOverline() const; + void SetStrikeout( FontStrikeout ); + FontStrikeout GetStrikeout() const; + void SetEmphasisMark( FontEmphasisMark ); + FontEmphasisMark GetEmphasisMark() const; + void SetWordLineMode( bool bWordLine ); + bool IsWordLineMode() const; + + void Merge( const Font& rFont ); + void GetFontAttributes( FontAttributes& rAttrs ) const; + + Font& operator=( const Font& ); + Font& operator=( Font&& ) noexcept; + bool operator==( const Font& ) const; + bool operator!=( const Font& rFont ) const + { return !(Font::operator==( rFont )); } + bool IsSameInstance( const Font& ) const; + + friend VCL_DLLPUBLIC SvStream& ::ReadFont( SvStream& rIStm, vcl::Font& ); + friend VCL_DLLPUBLIC SvStream& ::WriteFont( SvStream& rOStm, const vcl::Font& ); + + static Font identifyFont( const void* pBuffer, sal_uInt32 nLen ); + + typedef o3tl::cow_wrapper< ImplFont > ImplType; + + inline bool IsUnderlineAbove() const; + +private: + ImplType mpImplFont; +}; + +inline bool Font::IsUnderlineAbove() const +{ + if (!IsVertical()) + return false; + // the underline is right for Japanese only + return (LANGUAGE_JAPANESE == GetLanguage()) || + (LANGUAGE_JAPANESE == GetCJKContextLanguage()); +} + +} + +#endif // _VCL_FONT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/font/Feature.hxx b/include/vcl/font/Feature.hxx new file mode 100644 index 000000000..0b9124f6f --- /dev/null +++ b/include/vcl/font/Feature.hxx @@ -0,0 +1,124 @@ +/* -*- 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_FONT_FEATURE_HXX +#define INCLUDED_VCL_FONT_FEATURE_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <vector> + +namespace vcl +{ +namespace font +{ +constexpr uint32_t featureCode(const char sFeature[4]) +{ + return static_cast<uint32_t>(sFeature[0]) << 24U | static_cast<uint32_t>(sFeature[1]) << 16U + | static_cast<uint32_t>(sFeature[2]) << 8U | static_cast<uint32_t>(sFeature[3]); +} + +VCL_DLLPUBLIC OUString featureCodeAsString(uint32_t nFeature); + +enum class FeatureParameterType +{ + BOOL, + ENUM +}; + +enum class FeatureType +{ + OpenType, + Graphite +}; + +struct VCL_DLLPUBLIC FeatureParameter +{ +private: + uint32_t m_nCode; + OUString m_sDescription; + const char* m_pDescriptionID; + +public: + FeatureParameter(uint32_t nCode, OUString aDescription); + FeatureParameter(uint32_t nCode, const char* pDescriptionID); + + uint32_t getCode() const; + OUString getDescription() const; +}; + +class VCL_DLLPUBLIC FeatureDefinition +{ +private: + OUString m_sDescription; + const char* m_pDescriptionID; + OUString m_sNumericPart; + uint32_t m_nCode; + uint32_t m_nDefault; + FeatureParameterType m_eType; + // the index of the parameter defines the enum value, string is the description + std::vector<FeatureParameter> m_aEnumParameters; + +public: + FeatureDefinition(); + FeatureDefinition(uint32_t nCode, OUString const& rDescription, + FeatureParameterType eType = FeatureParameterType::BOOL, + std::vector<FeatureParameter> const& rEnumParameters + = std::vector<FeatureParameter>{}, + uint32_t nDefault = 0); + FeatureDefinition(uint32_t nCode, const char* pDescriptionID, + OUString const& rNumericPart = OUString()); + FeatureDefinition(uint32_t nCode, const char* pDescriptionID, + std::vector<FeatureParameter> aEnumParameters); + + const std::vector<FeatureParameter>& getEnumParameters() const; + uint32_t getCode() const; + OUString getDescription() const; + FeatureParameterType getType() const; + uint32_t getDefault() const; + + operator bool() const; +}; + +struct VCL_DLLPUBLIC FeatureID +{ + uint32_t m_aFeatureCode; + uint32_t m_aScriptCode; + uint32_t m_aLanguageCode; +}; + +struct Feature +{ + Feature(); + Feature(FeatureID const& rID, FeatureType eType); + + FeatureID m_aID; + FeatureType m_eType; + FeatureDefinition m_aDefinition; +}; + +// This is basically duplicates hb_feature_t to avoid including HarfBuzz +// headers here, so the member types should remain compatible. +struct FeatureSetting +{ + FeatureSetting(OString feature); + + uint32_t m_nTag; + uint32_t m_nValue; + unsigned int m_nStart; + unsigned int m_nEnd; +}; + +} // end font namespace + +} // end vcl namespace + +#endif // INCLUDED_VCL_FONT_FEATURE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/font/FeatureParser.hxx b/include/vcl/font/FeatureParser.hxx new file mode 100644 index 000000000..5674e2d31 --- /dev/null +++ b/include/vcl/font/FeatureParser.hxx @@ -0,0 +1,51 @@ +/* -*- 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_FONT_FEATUREPASER_HXX +#define INCLUDED_VCL_FONT_FEATUREPASER_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <vector> +#include <unordered_map> + +#include <vcl/font/Feature.hxx> + +namespace vcl +{ +namespace font +{ +// These must not conflict with font name lists which use ; and , +constexpr const char FeaturePrefix = ':'; +constexpr const char FeatureSeparator = '&'; + +VCL_DLLPUBLIC OUString trimFontNameFeatures(OUString const& rFontName); + +class VCL_DLLPUBLIC FeatureParser +{ +private: + OUString m_sLanguage; + std::vector<FeatureSetting> m_aFeatures; + +public: + FeatureParser(OUString const& sFontName); + + OUString const& getLanguage() const { return m_sLanguage; } + + std::vector<FeatureSetting> const& getFeatures() const { return m_aFeatures; } + + std::unordered_map<uint32_t, uint32_t> getFeaturesMap() const; +}; + +} // end font namespace +} // end vcl namespace + +#endif // INCLUDED_VCL_FONT_FEATUREPASER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fontcapabilities.hxx b/include/vcl/fontcapabilities.hxx new file mode 100644 index 000000000..9698be7a5 --- /dev/null +++ b/include/vcl/fontcapabilities.hxx @@ -0,0 +1,203 @@ +/* -*- 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_FONTCAPABILITIES_HXX +#define INCLUDED_VCL_FONTCAPABILITIES_HXX + +#include <optional> +#include <bitset> + +//See OS/2 table, i.e. http://www.microsoft.com/typography/otspec/os2.htm#ur +namespace vcl +{ + namespace UnicodeCoverage + { + enum UnicodeCoverageEnum + { + BASIC_LATIN = 0, + LATIN_1_SUPPLEMENT = 1, + LATIN_EXTENDED_A = 2, + LATIN_EXTENDED_B = 3, + IPA_EXTENSIONS = 4, + SPACING_MODIFIER_LETTERS = 5, + COMBINING_DIACRITICAL_MARKS = 6, + GREEK_AND_COPTIC = 7, + COPTIC = 8, + CYRILLIC = 9, + ARMENIAN = 10, + HEBREW = 11, + VAI = 12, + ARABIC = 13, + NKO = 14, + DEVANAGARI = 15, + BENGALI = 16, + GURMUKHI = 17, + GUJARATI = 18, + ODIA = 19, + TAMIL = 20, + TELUGU = 21, + KANNADA = 22, + MALAYALAM = 23, + THAI = 24, + LAO = 25, + GEORGIAN = 26, + BALINESE = 27, + HANGUL_JAMO = 28, + LATIN_EXTENDED_ADDITIONAL = 29, + GREEK_EXTENDED = 30, + GENERAL_PUNCTUATION = 31, + SUPERSCRIPTS_AND_SUBSCRIPTS = 32, + CURRENCY_SYMBOLS = 33, + COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS = 34, + LETTERLIKE_SYMBOLS = 35, + NUMBER_FORMS = 36, + ARROWS = 37, + MATHEMATICAL_OPERATORS = 38, + MISCELLANEOUS_TECHNICAL = 39, + CONTROL_PICTURES = 40, + OPTICAL_CHARACTER_RECOGNITION = 41, + ENCLOSED_ALPHANUMERICS = 42, + BOX_DRAWING = 43, + BLOCK_ELEMENTS = 44, + GEOMETRIC_SHAPES = 45, + MISCELLANEOUS_SYMBOLS = 46, + DINGBATS = 47, + CJK_SYMBOLS_AND_PUNCTUATION = 48, + HIRAGANA = 49, + KATAKANA = 50, + BOPOMOFO = 51, + HANGUL_COMPATIBILITY_JAMO = 52, + PHAGS_PA = 53, + ENCLOSED_CJK_LETTERS_AND_MONTHS = 54, + CJK_COMPATIBILITY = 55, + HANGUL_SYLLABLES = 56, + NONPLANE_0 = 57, + PHOENICIAN = 58, + CJK_UNIFIED_IDEOGRAPHS = 59, + PRIVATE_USE_AREA_PLANE_0 = 60, + CJK_STROKES = 61, + ALPHABETIC_PRESENTATION_FORMS = 62, + ARABIC_PRESENTATION_FORMS_A = 63, + COMBINING_HALF_MARKS = 64, + VERTICAL_FORMS = 65, + SMALL_FORM_VARIANTS = 66, + ARABIC_PRESENTATION_FORMS_B = 67, + HALFWIDTH_AND_FULLWIDTH_FORMS = 68, + SPECIALS = 69, + TIBETAN = 70, + SYRIAC = 71, + THAANA = 72, + SINHALA = 73, + MYANMAR = 74, + ETHIOPIC = 75, + CHEROKEE = 76, + UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS = 77, + OGHAM = 78, + RUNIC = 79, + KHMER = 80, + MONGOLIAN = 81, + BRAILLE_PATTERNS = 82, + YI_SYLLABLES = 83, + TAGALOG = 84, + OLD_ITALIC = 85, + GOTHIC = 86, + DESERET = 87, + BYZANTINE_MUSICAL_SYMBOLS = 88, + MATHEMATICAL_ALPHANUMERIC_SYMBOLS = 89, + PRIVATE_USE_PLANE_15 = 90, + VARIATION_SELECTORS = 91, + TAGS = 92, + LIMBU = 93, + TAI_LE = 94, + NEW_TAI_LUE = 95, + BUGINESE = 96, + GLAGOLITIC = 97, + TIFINAGH = 98, + YIJING_HEXAGRAM_SYMBOLS = 99, + SYLOTI_NAGRI = 100, + LINEAR_B_SYLLABARY = 101, + ANCIENT_GREEK_NUMBERS = 102, + UGARITIC = 103, + OLD_PERSIAN = 104, + SHAVIAN = 105, + OSMANYA = 106, + CYPRIOT_SYLLABARY = 107, + KHAROSHTHI = 108, + TAI_XUAN_JING_SYMBOLS = 109, + CUNEIFORM = 110, + COUNTING_ROD_NUMERALS = 111, + SUNDANESE = 112, + LEPCHA = 113, + OL_CHIKI = 114, + SAURASHTRA = 115, + KAYAH_LI = 116, + REJANG = 117, + CHAM = 118, + ANCIENT_SYMBOLS = 119, + PHAISTOS_DISC = 120, + CARIAN = 121, + DOMINO_TILES = 122, + RESERVED1 = 123, + RESERVED2 = 124, + RESERVED3 = 125, + RESERVED4 = 126, + RESERVED5 = 127, + MAX_UC_ENUM = 128 + }; + }; + + namespace CodePageCoverage + { + enum CodePageCoverageEnum + { + CP1252 = 0, + CP1250 = 1, + CP1251 = 2, + CP1253 = 3, + CP1254 = 4, + CP1255 = 5, + CP1256 = 6, + CP1257 = 7, + CP1258 = 8, + CP874 = 16, + CP932 = 17, + CP936 = 18, + CP949 = 19, + CP950 = 20, + CP1361 = 21, + CP869 = 48, + CP866 = 49, + CP865 = 50, + CP864 = 51, + CP863 = 52, + CP862 = 53, + CP861 = 54, + CP860 = 55, + CP857 = 56, + CP855 = 57, + CP852 = 58, + CP775 = 59, + CP737 = 60, + CP780 = 61, + CP850 = 62, + CP437 = 63, + MAX_CP_ENUM = 64 + }; + }; + + struct FontCapabilities + { + std::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> oUnicodeRange; + std::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> oCodePageRange; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/fontcharmap.hxx b/include/vcl/fontcharmap.hxx new file mode 100644 index 000000000..2a4e1dd08 --- /dev/null +++ b/include/vcl/fontcharmap.hxx @@ -0,0 +1,168 @@ +/* -*- 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_FONTCHARMAP_HXX +#define INCLUDED_FONTCHARMAP_HXX + +#include <vcl/dllapi.h> +#include <tools/ref.hxx> + +class ImplFontCharMap; +class CmapResult; +class FontCharMap; +class OutputDevice; + +typedef sal_uInt32 sal_UCS4; +typedef tools::SvRef<ImplFontCharMap> ImplFontCharMapRef; +typedef tools::SvRef<FontCharMap> FontCharMapRef; + +class VCL_DLLPUBLIC FontCharMap : public SvRefBase +{ +public: + /** A new FontCharMap is created based on a "default" map, which includes + all codepoints in the Unicode BMP range, including surrogates. + **/ + FontCharMap(); + FontCharMap( const CmapResult& rCR ); + virtual ~FontCharMap() override; + + /** Get the default font character map + + @returns the default font character map. + */ + static FontCharMapRef GetDefaultMap( bool bSymbols ); + + /** Determines if the font character map is the "default". The default map + includes all codepoints in the Unicode BMP range, including surrogates. + + @returns true if default map, false if not default map. + */ + bool IsDefaultMap() const; + + /** Does the font character map include the UCS4 character? + + @returns true if character exists in font character map, false is not. + */ + bool HasChar( sal_UCS4 ) const; + + /** Returns the number of chars supported by the font, which + are inside the unicode range from cMin to cMax (inclusive). + + @param cMin Lowest codepoint in range to be counted + @param cMax Highest codepoint in range to be counted + + @returns number of characters in the font charmap between the two + codepoints. + */ + int CountCharsInRange( sal_UCS4 cMin, sal_UCS4 cMax ) const; + + /** Get the number of characters in the font character map. + + @returns number of characters in the font character map. + */ + int GetCharCount() const; + + /** Get the first character in the font character map. + + @returns first character in the font character map. + */ + sal_UCS4 GetFirstChar() const; + + /** Get the last character in the font character map. + + @returns last character in the font character map. + */ + sal_UCS4 GetLastChar() const; + + /** Get the next character in the font character map. This is important + because character maps (e.g. the default map which holds the characters + in the BMP plane) can have discontiguous ranges. + + @param cChar Character from which to find next character + + @returns next character in the font character map. + */ + sal_UCS4 GetNextChar( sal_UCS4 cChar ) const; + + /** Get the previous character in the font character map. This is important + because character maps (e.g. the default map which holds the characters + in the BMP plane) can have discontiguous ranges. + + @param cChar Character from which to find previous character + + @returns previous character in the font character map. + */ + sal_UCS4 GetPrevChar( sal_UCS4 cChar ) const; + + /** Get the index of a particular character in the font character map. The + index is different from the codepoint, because font character maps can + + determine the index. + + @param cChar Character used to find index number + + @returns Index of character in font character map. + */ + int GetIndexFromChar( sal_UCS4 cChar ) const; + + /** Get the character at a particular index in the font character map. The + index is different from the codepoint, because font character maps can + + determine the character. + + @param nCharIndex Index used to find the character + + @returns Character in font character map. + */ + sal_UCS4 GetCharFromIndex( int nCharIndex ) const; + + int GetGlyphIndex( sal_UCS4 ) const; + +private: + ImplFontCharMapRef mpImplFontCharMap; + + friend class ::OutputDevice; + + int findRangeIndex( sal_UCS4 ) const; + + FontCharMap( ImplFontCharMapRef const & pIFCMap ); + + // prevent assignment and copy construction + FontCharMap( const FontCharMap& ) = delete; + void operator=( const FontCharMap& ) = delete; +}; + +// CmapResult is a normalized version of the many CMAP formats +class VCL_PLUGIN_PUBLIC CmapResult +{ +public: + explicit CmapResult( bool bSymbolic = false, + const sal_UCS4* pRangeCodes = nullptr, int nRangeCount = 0 ); + + const sal_UCS4* mpRangeCodes; + const int* mpStartGlyphs; + const sal_uInt16* mpGlyphIds; + int mnRangeCount; + bool mbSymbolic; + bool mbRecoded; +}; + +#endif // INCLUDED_FONTCHARMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gdimetafiletools.hxx b/include/vcl/gdimetafiletools.hxx new file mode 100644 index 000000000..923d49c21 --- /dev/null +++ b/include/vcl/gdimetafiletools.hxx @@ -0,0 +1,58 @@ +/* -*- 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_GDIMETAFILETOOLS_HXX +#define INCLUDED_VCL_GDIMETAFILETOOLS_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> + +class GDIMetaFile; + + +// #i121267# Added tooling to be able to support old exporters which are based on +// metafiles as graphic content, but do not implement using the contained clip +// regions. +// The given metafile will internally clip it's graphic content against the +// included clip regions so that it is safe to ignore clip actions there. This +// is not done completely, but implemented and extended as needed (on demand) +// since all this is a workaround; the better and long term solution will be to +// reimplement these im/exports to use primitives and not metafiles as base +// information. + +void VCL_DLLPUBLIC clipMetafileContentAgainstOwnRegions(GDIMetaFile& rSource); + + +// Allow to check if a Metafile contains clipping or not + +bool VCL_DLLPUBLIC usesClipActions(const GDIMetaFile& rSource); + +// hook to access metafile members in classes of modules above vcl. Currently +// used in MetafilePrimitive2D to be able to access the local Metafile member +// e.g. from vcl module +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetafileAccessor +{ +public: + virtual void accessMetafile(GDIMetaFile& rTargetMetafile) const = 0; + virtual ~MetafileAccessor(); +}; + + +#endif // INCLUDED_VCL_GDIMETAFILETOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gdimtf.hxx b/include/vcl/gdimtf.hxx new file mode 100644 index 000000000..3727f6531 --- /dev/null +++ b/include/vcl/gdimtf.hxx @@ -0,0 +1,209 @@ +/* -*- 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_GDIMTF_HXX +#define INCLUDED_VCL_GDIMTF_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/vclptr.hxx> +#include <vector> + +class OutputDevice; +class MetaAction; +class SvStream; +class Color; +class BitmapEx; +namespace tools { + class Polygon; + class PolyPolygon; +} +class Gradient; +struct ImplMetaReadData; + +#define GDI_METAFILE_END (size_t(0xFFFFFFFF)) + +enum class MtfConversion +{ + N1BitThreshold, + N8BitGreys +}; + + +typedef Color (*ColorExchangeFnc)( const Color& rColor, const void* pColParam ); +typedef BitmapEx (*BmpExchangeFnc)( const BitmapEx& rBmpEx, const void* pBmpParam ); + +VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData = nullptr); +VCL_DLLPUBLIC SvStream& WriteGDIMetaFile( SvStream& rOStm, const GDIMetaFile& rGDIMetaFile ); + +class VCL_DLLPUBLIC GDIMetaFile final +{ +private: + ::std::vector< rtl::Reference<MetaAction> > m_aList; + size_t m_nCurrentActionElement; + + MapMode m_aPrefMapMode; + Size m_aPrefSize; + GDIMetaFile* m_pPrev; + GDIMetaFile* m_pNext; + VclPtr<OutputDevice> m_pOutDev; + bool m_bPause; + bool m_bRecord; + bool m_bUseCanvas; + + + SAL_DLLPRIVATE static Color ImplColAdjustFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpAdjustFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColConvertFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColMonoFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpMonoFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE static Color ImplColReplaceFnc( const Color& rColor, const void* pColParam ); + SAL_DLLPRIVATE static BitmapEx ImplBmpReplaceFnc( const BitmapEx& rBmpEx, const void* pBmpParam ); + + SAL_DLLPRIVATE void ImplExchangeColors( ColorExchangeFnc pFncCol, const void* pColParam, + BmpExchangeFnc pFncBmp, const void* pBmpParam ); + + SAL_DLLPRIVATE static Point ImplGetRotatedPoint( const Point& rPt, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE static tools::Polygon ImplGetRotatedPolygon( const tools::Polygon& rPoly, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE static tools::PolyPolygon ImplGetRotatedPolyPolygon( const tools::PolyPolygon& rPoly, const Point& rRotatePt, + const Size& rOffset, double fSin, double fCos ); + SAL_DLLPRIVATE static void ImplAddGradientEx( GDIMetaFile& rMtf, + const OutputDevice& rMapDev, + const tools::PolyPolygon& rPolyPoly, + const Gradient& rGrad ); + + SAL_DLLPRIVATE bool ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, Size rLogicDestSize ); + + void Linker( OutputDevice* pOut, bool bLink ); + +public: + GDIMetaFile(); + GDIMetaFile( const GDIMetaFile& rMtf ); + ~GDIMetaFile(); + + GDIMetaFile& operator=( const GDIMetaFile& rMtf ); + bool operator==( const GDIMetaFile& rMtf ) const; + bool operator!=( const GDIMetaFile& rMtf ) const { return !( *this == rMtf ); } + + void Clear(); + void Mirror( BmpMirrorFlags nMirrorFlags ); + void Move( long nX, long nY ); + // additional Move method getting specifics how to handle MapMode( MapUnit::MapPixel ) + void Move( long nX, long nY, long nDPIX, long nDPIY ); + void Scale( double fScaleX, double fScaleY ); + void Scale( const Fraction& rScaleX, const Fraction& rScaleY ); + void Rotate( long nAngle10 ); + void Clip( const tools::Rectangle& ); + bool HasTransparentActions() const; + + /* get the bound rect of the contained actions + * caveats: + * - clip actions will limit the contained actions, + * but the current clipregion of the passed OutputDevice will not + * - coordinates of actions will be transformed to preferred mapmode + * - the returned rectangle is relative to the preferred mapmode of the metafile + */ + tools::Rectangle GetBoundRect( OutputDevice& i_rReference, tools::Rectangle* pHairline = nullptr ) const; + + void Adjust( short nLuminancePercent, short nContrastPercent, + short nChannelRPercent = 0, short nChannelGPercent = 0, + short nChannelBPercent = 0, double fGamma = 1.0, + bool bInvert = false, bool msoBrightness = false ); + + void Convert( MtfConversion eConversion ); + void ReplaceColors( const Color* pSearchColors, const Color* rReplaceColors, + sal_uLong nColorCount ); + + GDIMetaFile GetMonochromeMtf( const Color& rCol ) const; + + void Record( OutputDevice* pOutDev ); + bool IsRecord() const { return m_bRecord; } + + void Play( GDIMetaFile& rMtf ); + void Play( OutputDevice* pOutDev, size_t nPos = GDI_METAFILE_END ); + void Play( OutputDevice* pOutDev, const Point& rPos, + const Size& rSize ); + + void Pause( bool bPause ); + bool IsPause() const { return m_bPause; } + + void Stop(); + + void WindStart(); + void WindPrev(); + + size_t GetActionSize() const; + + void AddAction(const rtl::Reference<MetaAction>& pAction); + void AddAction(const rtl::Reference<MetaAction>& pAction, size_t nPos); + void push_back(const rtl::Reference<MetaAction>& pAction); + /** + * @param pAction takes ownership + * @param nAction the action to replace + */ + void ReplaceAction( rtl::Reference<MetaAction> pAction, size_t nAction ); + + MetaAction* FirstAction(); + MetaAction* NextAction(); + MetaAction* GetAction( size_t nAction ) const; + MetaAction* GetCurAction() const { return GetAction( m_nCurrentActionElement ); } + + const Size& GetPrefSize() const { return m_aPrefSize; } + void SetPrefSize( const Size& rSize ) { m_aPrefSize = rSize; } + + const MapMode& GetPrefMapMode() const { return m_aPrefMapMode; } + void SetPrefMapMode( const MapMode& rMapMode ) { m_aPrefMapMode = rMapMode; } + + + BitmapChecksum GetChecksum() const; + sal_uLong GetSizeBytes() const; + + // Methods for reading and writing the new formats; + // the Read method also reads the old format + SvStream& Read( SvStream& rIStm ); + SvStream& Write( SvStream& rOStm ); + + // Stream-operators write (still) the old format + // and read both the old and the new format + friend VCL_DLLPUBLIC SvStream& ReadGDIMetaFile(SvStream& rIStm, GDIMetaFile& rGDIMetaFile, ImplMetaReadData* pReadData); + friend VCL_DLLPUBLIC SvStream& WriteGDIMetaFile(SvStream& rOStm, const GDIMetaFile& rGDIMetaFile); + + /// Creates an antialiased thumbnail + bool CreateThumbnail(BitmapEx& rBitmapEx, + BmpConversion nColorConversion = BmpConversion::N24Bit, + BmpScaleFlag nScaleFlag = BmpScaleFlag::BestQuality) const; + + void UseCanvas( bool _bUseCanvas ); + bool GetUseCanvas() const { return m_bUseCanvas; } + + /// Dumps the meta actions as XML in metafile.xml. + void dumpAsXml(const char* pFileName = nullptr) const; +}; + +#endif // INCLUDED_VCL_GDIMTF_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx new file mode 100644 index 000000000..0e116234f --- /dev/null +++ b/include/vcl/gfxlink.hxx @@ -0,0 +1,111 @@ +/* -*- 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_GFXLINK_HXX +#define INCLUDED_VCL_GFXLINK_HXX + +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <vcl/dllapi.h> +#include <vcl/mapmod.hxx> +#include <memory> + +class SvStream; + +/** GfxLink graphic types that are supported by GfxLink. + * + * It is important that the numbers for native types stay the same, because + * they are used in serialization to MTF. + */ +enum class GfxLinkType +{ + NONE = 0, + EpsBuffer = 1, + NativeGif = 2, + NativeJpg = 3, + NativePng = 4, + NativeTif = 5, + NativeWmf = 6, + NativeMet = 7, + NativePct = 8, + NativeSvg = 9, + NativeMov = 10, + NativeBmp = 11, + NativePdf = 12, // If a new type is added, make sure to change NativeLast too + + // Alias for when the first native type starts and last native + // type ends. + NativeFirst = NativeGif, + NativeLast = NativePdf, +}; + +class Graphic; + +class VCL_DLLPUBLIC GfxLink +{ +private: + GfxLinkType meType; + sal_uInt32 mnUserId; + mutable std::shared_ptr<sal_uInt8> mpSwapInData; + mutable size_t maHash; + sal_uInt32 mnSwapInDataSize; + MapMode maPrefMapMode; + Size maPrefSize; + bool mbPrefMapModeValid; + bool mbPrefSizeValid; + + SAL_DLLPRIVATE std::shared_ptr<sal_uInt8> GetSwapInData() const; +public: + GfxLink(); + + // pBuff = The Graphic data. This class takes ownership of this + GfxLink( std::unique_ptr<sal_uInt8[]> pBuf, sal_uInt32 nBufSize, GfxLinkType nType ); + + bool operator==( const GfxLink& ) const; + + GfxLinkType GetType() const { return meType;} + + size_t GetHash() const; + + void SetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; } + sal_uInt32 GetUserId() const { return mnUserId; } + + sal_uInt32 GetDataSize() const { return mnSwapInDataSize;} + const sal_uInt8* GetData() const; + + const Size& GetPrefSize() const { return maPrefSize;} + void SetPrefSize( const Size& rPrefSize ); + bool IsPrefSizeValid() const { return mbPrefSizeValid;} + + const MapMode& GetPrefMapMode() const { return maPrefMapMode;} + void SetPrefMapMode( const MapMode& rPrefMapMode ); + bool IsPrefMapModeValid() const { return mbPrefMapModeValid;} + + bool IsNative() const; + + bool LoadNative( Graphic& rGraphic ); + + bool ExportNative( SvStream& rOStream ) const; + + bool IsEMF() const; // WMF & EMF stored under the same type (NativeWmf) +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/glxtestprocess.hxx b/include/vcl/glxtestprocess.hxx new file mode 100644 index 000000000..848135442 --- /dev/null +++ b/include/vcl/glxtestprocess.hxx @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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_INCLUDE_VCL_GLXTESTPROCESS_HXX + +#include <sal/config.h> +#include <config_features.h> + +#if defined(UNX) && !defined MACOSX && !defined IOS && !defined ANDROID && HAVE_FEATURE_UI \ + && HAVE_FEATURE_OPENGL +/* Run test for OpenGL support in own process to avoid crash with broken + * OpenGL drivers. Start process as early as possible. + * In non-headless mode, the process will be reaped in X11OpenGLDeviceInfo::GetData + * (vcl/opengl/x11/X11DeviceInfo.cxx). In headless mode, the process will be reaped late in + * Desktop::Main (desktop/source/app/app.cxx). + */ + +bool fire_glxtest_process(); + +void reap_glxtest_process(); + +#else + +inline bool fire_glxtest_process() { return true; } + +inline void reap_glxtest_process() {} + +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/glyphitem.hxx b/include/vcl/glyphitem.hxx new file mode 100644 index 000000000..7634bd3a4 --- /dev/null +++ b/include/vcl/glyphitem.hxx @@ -0,0 +1,50 @@ +/* -*- 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_GLYPHITEM_HXX +#define INCLUDED_VCL_GLYPHITEM_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> + +typedef sal_uInt16 sal_GlyphId; + +class SalLayoutGlyphsImpl; + +class VCL_DLLPUBLIC SalLayoutGlyphs final +{ + friend class SalLayoutGlyphsImpl; + SalLayoutGlyphsImpl* m_pImpl; + +public: + SalLayoutGlyphs(); + SalLayoutGlyphs(const SalLayoutGlyphs&); + ~SalLayoutGlyphs(); + + SalLayoutGlyphs& operator=(const SalLayoutGlyphs&); + + SalLayoutGlyphsImpl* Impl() const { return m_pImpl; } + + bool IsValid() const; + void Invalidate(); +}; + +#endif // INCLUDED_VCL_GLYPHITEM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/gradient.hxx b/include/vcl/gradient.hxx new file mode 100644 index 000000000..aee89e06b --- /dev/null +++ b/include/vcl/gradient.hxx @@ -0,0 +1,88 @@ +/* -*- 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_GRADIENT_HXX +#define INCLUDED_VCL_GRADIENT_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> + +#include <vcl/vclenum.hxx> +#include <o3tl/cow_wrapper.hxx> + + +namespace tools { class Rectangle; } + +class Point; +class SvStream; + +class VCL_DLLPUBLIC Gradient +{ +private: + class Impl; + ::o3tl::cow_wrapper<Impl> mpImplGradient; + +public: + Gradient(); + Gradient( const Gradient& rGradient ); + Gradient( Gradient&& rGradient ); + Gradient( GradientStyle eStyle, + const Color& rStartColor, + const Color& rEndColor ); + ~Gradient(); + + void SetStyle( GradientStyle eStyle ); + GradientStyle GetStyle() const; + + void SetStartColor( const Color& rColor ); + const Color& GetStartColor() const; + void SetEndColor( const Color& rColor ); + const Color& GetEndColor() const; + + void SetAngle( sal_uInt16 nAngle ); + sal_uInt16 GetAngle() const; + + void SetBorder( sal_uInt16 nBorder ); + sal_uInt16 GetBorder() const; + void SetOfsX( sal_uInt16 nOfsX ); + sal_uInt16 GetOfsX() const; + void SetOfsY( sal_uInt16 nOfsY ); + sal_uInt16 GetOfsY() const; + + void SetStartIntensity( sal_uInt16 nIntens ); + sal_uInt16 GetStartIntensity() const; + void SetEndIntensity( sal_uInt16 nIntens ); + sal_uInt16 GetEndIntensity() const; + + void SetSteps( sal_uInt16 nSteps ); + sal_uInt16 GetSteps() const; + + void GetBoundRect( const tools::Rectangle& rRect, tools::Rectangle &rBoundRect, Point& rCenter ) const; + + Gradient& operator=( const Gradient& rGradient ); + Gradient& operator=( Gradient&& rGradient ); + bool operator==( const Gradient& rGradient ) const; + bool operator!=( const Gradient& rGradient ) const + { return !(Gradient::operator==( rGradient )); } +}; + +#endif // INCLUDED_VCL_GRADIENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx new file mode 100644 index 000000000..f6a47e43b --- /dev/null +++ b/include/vcl/graph.hxx @@ -0,0 +1,218 @@ +/* -*- 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_GRAPH_HXX +#define INCLUDED_VCL_GRAPH_HXX + +#include <memory> +#include <vcl/dllapi.h> +#include <tools/solar.h> +#include <rtl/ustring.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/animate/Animation.hxx> +#include <vcl/gfxlink.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <vcl/vectorgraphicdata.hxx> +#include <basegfx/vector/b2dsize.hxx> +#include <vcl/GraphicExternalLink.hxx> + +enum class GraphicType +{ + NONE, + Bitmap, + GdiMetafile, + Default +}; + +namespace com::sun::star::graphic { class XGraphic; } +namespace vcl { class Font; } + +class Bitmap; +class GDIMetaFile; +class SvStream; +class ImpGraphic; +class OutputDevice; +class GraphicReader; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC GraphicConversionParameters +{ +private: + Size maSizePixel; // default is (0,0) + + bool mbUnlimitedSize : 1; // default is false + bool mbAntiAliase : 1; // default is false + bool mbSnapHorVerLines : 1; // default is false + +public: + GraphicConversionParameters( + const Size& rSizePixel = Size(), + bool bUnlimitedSize = false, + bool bAntiAliase = false, + bool bSnapHorVerLines = false) + : maSizePixel(rSizePixel), + mbUnlimitedSize(bUnlimitedSize), + mbAntiAliase(bAntiAliase), + mbSnapHorVerLines(bSnapHorVerLines) + { + } + + // data read access + const Size& getSizePixel() const { return maSizePixel; } + bool getUnlimitedSize() const { return mbUnlimitedSize; } + bool getAntiAliase() const { return mbAntiAliase; } + bool getSnapHorVerLines() const { return mbSnapHorVerLines; } +}; + +class Image; +class VCL_DLLPUBLIC Graphic +{ +private: + std::shared_ptr<ImpGraphic> mxImpGraphic; + SAL_DLLPRIVATE void ImplTestRefCount(); + +public: + SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return mxImpGraphic.get(); } + + Graphic(); + Graphic( const GraphicExternalLink& rGraphicLink ); + Graphic( const Graphic& rGraphic ); + Graphic( Graphic&& rGraphic ) noexcept; + Graphic( const Bitmap& rBmp ); + Graphic( const Image& rImage ); + Graphic( const BitmapEx& rBmpEx ); + Graphic( const std::shared_ptr<VectorGraphicData>& rVectorGraphicDataPtr ); + Graphic( const Animation& rAnimation ); + Graphic( const GDIMetaFile& rMtf ); + Graphic( const css::uno::Reference< css::graphic::XGraphic >& rxGraphic ); + + Graphic& operator=( const Graphic& rGraphic ); + Graphic& operator=( Graphic&& rGraphic ) noexcept; + bool operator==( const Graphic& rGraphic ) const; + bool operator!=( const Graphic& rGraphic ) const; + + bool IsNone() const; + + void Clear(); + + GraphicType GetType() const; + void SetDefaultType(); + bool IsSupportedGraphic() const; + + bool IsTransparent() const; + bool IsAlpha() const; + bool IsAnimated() const; + bool IsEPS() const; + + bool isAvailable() const; + bool makeAvailable(); + + // #i102089# Access of Bitmap potentially will have to rasterconvert the Graphic + // if it is a MetaFile. To be able to control this conversion it is necessary to + // allow giving parameters which control AntiAliasing and LineSnapping of the + // MetaFile when played. Defaults will use a no-AAed, not snapped conversion as + // before. + BitmapEx GetBitmapEx(const GraphicConversionParameters& rParameters = GraphicConversionParameters()) const; + /// Gives direct access to the contained BitmapEx. + const BitmapEx& GetBitmapExRef() const; + + Animation GetAnimation() const; + const GDIMetaFile& GetGDIMetaFile() const; + + css::uno::Reference< css::graphic::XGraphic > GetXGraphic() const; + + Size GetPrefSize() const; + void SetPrefSize( const Size& rPrefSize ); + + MapMode GetPrefMapMode() const; + void SetPrefMapMode( const MapMode& rPrefMapMode ); + + basegfx::B2DSize GetPPI() const; + + Size GetSizePixel( const OutputDevice* pRefDevice = nullptr ) const; + + sal_uLong GetSizeBytes() const; + + void Draw( OutputDevice* pOutDev, + const Point& rDestPt ) const; + void Draw( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize ) const; + static void DrawEx( OutputDevice* pOutDev, const OUString& rText, + vcl::Font& rFont, const BitmapEx& rBitmap, + const Point& rDestPt, const Size& rDestSize ); + + void StartAnimation( OutputDevice* pOutDev, + const Point& rDestPt, + const Size& rDestSize, + long nExtraData = 0, + OutputDevice* pFirstFrameOutDev = nullptr ); + void StopAnimation( OutputDevice* pOutputDevice, + long nExtraData ); + + void SetAnimationNotifyHdl( const Link<Animation*,void>& rLink ); + Link<Animation*,void> GetAnimationNotifyHdl() const; + + sal_uInt32 GetAnimationLoopCount() const; + + BitmapChecksum GetChecksum() const; + + OUString getOriginURL() const; + void setOriginURL(OUString const & rOriginURL); + + OString getUniqueID() const; + + std::shared_ptr<GraphicReader>& GetReaderContext(); + void SetReaderContext( const std::shared_ptr<GraphicReader> &pReader ); + void SetDummyContext(bool value); + bool IsDummyContext() const; + + void SetGfxLink(const std::shared_ptr<GfxLink>& rGfxLink); + std::shared_ptr<GfxLink> GetSharedGfxLink() const; + GfxLink GetGfxLink() const; + bool IsGfxLink() const; + + bool ExportNative( SvStream& rOStream ) const; + + friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& rGraphic); + friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& rGraphic); + + const std::shared_ptr<VectorGraphicData>& getVectorGraphicData() const; + + /// Get the page number of the multi-page source this Graphic is rendered from. + sal_Int32 getPageNumber() const; + + static css::uno::Sequence<sal_Int8> getUnoTunnelId(); +}; + +namespace std { + +template <> +struct hash<Graphic> +{ + std::size_t operator()(Graphic const & rGraphic) const + { + return static_cast<std::size_t>(rGraphic.GetChecksum()); + } +}; + +} // end namespace std + +#endif // INCLUDED_VCL_GRAPH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx new file mode 100644 index 000000000..7ce85fd87 --- /dev/null +++ b/include/vcl/graphicfilter.hxx @@ -0,0 +1,337 @@ +/* -*- 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_GRAPHICFILTER_HXX +#define INCLUDED_VCL_GRAPHICFILTER_HXX + +#include <tools/gen.hxx> +#include <vcl/dllapi.h> +#include <vcl/graph.hxx> +#include <vcl/errcode.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <memory> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template <class E> class Sequence; } + +class INetURLObject; + +class FilterConfigCache; +class SvStream; +struct WmfExternal; +struct ConvertData; + +#define ERRCODE_GRFILTER_OPENERROR ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 1) +#define ERRCODE_GRFILTER_IOERROR ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 2) +#define ERRCODE_GRFILTER_FORMATERROR ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 3) +#define ERRCODE_GRFILTER_VERSIONERROR ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 4) +#define ERRCODE_GRFILTER_FILTERERROR ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 5) +#define ERRCODE_GRFILTER_TOOBIG ErrCode(ErrCodeArea::Vcl, ErrCodeClass::General, 7) + +#define GRFILTER_OUTHINT_GREY 1 + +#define GRFILTER_FORMAT_NOTFOUND (sal_uInt16(0xFFFF)) +#define GRFILTER_FORMAT_DONTKNOW (sal_uInt16(0xFFFF)) + +enum class GraphicFilterImportFlags +{ + NONE = 0x000, + SetLogsizeForJpeg = 0x001, + DontSetLogsizeForJpeg = 0x002, + /// Only create a bitmap, do not read pixel data. + OnlyCreateBitmap = 0x020, + /// Read pixel data into an existing bitmap. + UseExistingBitmap = 0x040, +}; +namespace o3tl +{ + template<> struct typed_flags<GraphicFilterImportFlags> : is_typed_flags<GraphicFilterImportFlags, 0x0063> {}; +} + +#define IMP_BMP "SVBMP" +#define IMP_MOV "SVMOV" +#define IMP_SVMETAFILE "SVMETAFILE" +#define IMP_WMF "SVWMF" +#define IMP_EMF "SVEMF" +#define IMP_GIF "SVIGIF" +#define IMP_PNG "SVIPNG" +#define IMP_JPEG "SVIJPEG" +#define IMP_XBM "SVIXBM" +#define IMP_XPM "SVIXPM" +#define IMP_SVG "SVISVG" +#define IMP_PDF "SVIPDF" +#define EXP_BMP "SVBMP" +#define EXP_SVMETAFILE "SVMETAFILE" +#define EXP_WMF "SVWMF" +#define EXP_EMF "SVEMF" +#define EXP_JPEG "SVEJPEG" +#define EXP_SVG "SVESVG" +#define EXP_PDF "SVEPDF" +#define EXP_PNG "SVEPNG" + +#define BMP_SHORTNAME "BMP" +#define GIF_SHORTNAME "GIF" +#define JPG_SHORTNAME "JPG" +#define MET_SHORTNAME "MET" +#define PCT_SHORTNAME "PCT" +#define PNG_SHORTNAME "PNG" +#define SVM_SHORTNAME "SVM" +#define TIF_SHORTNAME "TIF" +#define WMF_SHORTNAME "WMF" +#define EMF_SHORTNAME "EMF" +#define SVG_SHORTNAME "SVG" +#define PDF_SHORTNAME "PDF" + +// Info class for all supported file formats + +enum class GraphicFileFormat +{ + NOT = 0x0000, + BMP = 0x0001, + GIF = 0x0002, + JPG = 0x0003, + PCD = 0x0004, + PCX = 0x0005, + PNG = 0x0006, + TIF = 0x0007, + XBM = 0x0008, + XPM = 0x0009, + PBM = 0x000a, + PGM = 0x000b, + PPM = 0x000c, + RAS = 0x000d, + TGA = 0x000e, + PSD = 0x000f, + EPS = 0x0010, + DXF = 0x00f1, + MET = 0x00f2, + PCT = 0x00f3, + // retired SGF = 0x00f4, + SVM = 0x00f5, + WMF = 0x00f6, + // retired SGV = 0x00f7, + EMF = 0x00f8, + SVG = 0x00f9 +}; + + +class VCL_DLLPUBLIC GraphicDescriptor final +{ + SvStream* pFileStm; + + OUString aPathExt; + Size aPixSize; + Size aLogSize; + sal_uInt16 nBitsPerPixel; + sal_uInt16 nPlanes; + GraphicFileFormat nFormat; + bool bOwnStream; + sal_uInt8 mnNumberOfImageComponents; + bool bIsTransparent; + bool bIsAlpha; + + void ImpConstruct(); + + bool ImpDetectBMP( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectGIF( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPCD( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPCX( SvStream& rStm ); + bool ImpDetectPNG( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectXBM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectXPM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPBM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPGM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPPM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectRAS( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectTGA( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPSD( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectEPS( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectDXF( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectMET( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPCT( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectSVM( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectWMF( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectEMF( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectSVG( SvStream& rStm, bool bExtendedInfo ); + GraphicDescriptor( const GraphicDescriptor& ) = delete; + GraphicDescriptor& operator=( const GraphicDescriptor& ) = delete; + +public: + + /** Ctor to set a filename + + Detect() must be called to identify the file + If the file has no unique header (Mtf's), the format + is determined from the extension */ + GraphicDescriptor( const INetURLObject& rPath ); + + /** Ctor using a stream + + Detect() must be called to identify the file + As some formats (Mtf's) do not have a unique header, it makes sense + to supply the file name (incl. ext.), so that the format can be + derived from the extension */ + GraphicDescriptor( SvStream& rInStream, const OUString* pPath ); + + ~GraphicDescriptor(); + + /** starts the detection + + if bExtendedInfo == true the file header is used to derive + as many properties as possible (size, color, etc.) */ + bool Detect( bool bExtendedInfo = false ); + + /** @return the file format, GraphicFileFormat::NOT if no format was recognized */ + GraphicFileFormat GetFileFormat() const { return nFormat; } + + /** @return graphic size in pixels or 0 size */ + const Size& GetSizePixel() const { return aPixSize; } + + /** @return the logical graphic size in 1/100mm or 0 size */ + const Size& GetSize_100TH_MM() const { return aLogSize; } + + /** @return bits/pixel or 0 **/ + sal_uInt16 GetBitsPerPixel() const { return nBitsPerPixel; } + + /** @return number of color channels */ + sal_uInt8 GetNumberOfImageComponents() const { return mnNumberOfImageComponents; } + + /** @return whether image supports transparency */ + bool IsTransparent() const { return bIsTransparent; } + + /** @return whether image supports alpha values for translucent colours */ + bool IsAlpha() const { return bIsAlpha; } + + /** @return filter number that is needed by the GraphFilter to read this format */ + static OUString GetImportFormatShortName( GraphicFileFormat nFormat ); +}; + +/** Information about errors during the GraphicFilter operation. */ +struct FilterErrorEx +{ + ErrCode nStreamError; + + FilterErrorEx() : nStreamError( ERRCODE_NONE ) {} +}; + +/** Class to import and export graphic formats. */ +class VCL_DLLPUBLIC GraphicFilter +{ +public: + GraphicFilter( bool bUseConfig = true ); + ~GraphicFilter(); + + sal_uInt16 GetImportFormatCount() const; + sal_uInt16 GetImportFormatNumber( const OUString& rFormatName ); + sal_uInt16 GetImportFormatNumberForShortName( const OUString& rShortName ); + sal_uInt16 GetImportFormatNumberForTypeName( const OUString& rType ); + OUString GetImportFormatName( sal_uInt16 nFormat ); + OUString GetImportFormatTypeName( sal_uInt16 nFormat ); +#ifdef _WIN32 + OUString GetImportFormatMediaType( sal_uInt16 nFormat ); +#endif + OUString GetImportFormatShortName( sal_uInt16 nFormat ); + OUString GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry ); + + sal_uInt16 GetExportFormatCount() const; + sal_uInt16 GetExportFormatNumber( const OUString& rFormatName ); + sal_uInt16 GetExportFormatNumberForMediaType( const OUString& rShortName ); + sal_uInt16 GetExportFormatNumberForShortName( const OUString& rShortName ); + OUString GetExportInternalFilterName( sal_uInt16 nFormat ); + sal_uInt16 GetExportFormatNumberForTypeName( const OUString& rType ); + OUString GetExportFormatName( sal_uInt16 nFormat ); + OUString GetExportFormatMediaType( sal_uInt16 nFormat ); + OUString GetExportFormatShortName( sal_uInt16 nFormat ); + OUString GetExportWildcard( sal_uInt16 nFormat ); + bool IsExportPixelFormat( sal_uInt16 nFormat ); + + ErrCode ExportGraphic( const Graphic& rGraphic, const INetURLObject& rPath, + sal_uInt16 nFormat, + const css::uno::Sequence< css::beans::PropertyValue >* pFilterData = nullptr ); + ErrCode ExportGraphic( const Graphic& rGraphic, const OUString& rPath, + SvStream& rOStm, sal_uInt16 nFormat, + const css::uno::Sequence< css::beans::PropertyValue >* pFilterData = nullptr ); + + ErrCode CanImportGraphic( const INetURLObject& rPath, + sal_uInt16 nFormat, + sal_uInt16 * pDeterminedFormat); + + ErrCode ImportGraphic( Graphic& rGraphic, const INetURLObject& rPath, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE ); + + ErrCode CanImportGraphic( const OUString& rPath, SvStream& rStream, + sal_uInt16 nFormat, + sal_uInt16 * pDeterminedFormat); + + ErrCode ImportGraphic( Graphic& rGraphic, const OUString& rPath, + SvStream& rStream, + sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW, + sal_uInt16 * pDeterminedFormat = nullptr, GraphicFilterImportFlags nImportFlags = GraphicFilterImportFlags::NONE, + WmfExternal const *pExtHeader = nullptr ); + + /// Imports multiple graphics. + /// + /// The resulting graphic is added to rGraphics on success, nullptr is added on failure. + void ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGraphics, std::vector< std::unique_ptr<SvStream> > vStreams); + + ErrCode ImportGraphic( Graphic& rGraphic, const OUString& rPath, + SvStream& rStream, + sal_uInt16 nFormat, + sal_uInt16 * pDeterminedFormat, GraphicFilterImportFlags nImportFlags, + const css::uno::Sequence< css::beans::PropertyValue >* pFilterData, + WmfExternal const *pExtHeader = nullptr ); + + // Setting sizeLimit limits how much will be read from the stream. + Graphic ImportUnloadedGraphic(SvStream& rIStream, sal_uInt64 sizeLimit = 0, const Size* pSizeHint = nullptr); + + const FilterErrorEx& GetLastError() const { return *pErrorEx;} + void ResetLastError(); + + Link<ConvertData&,bool> GetFilterCallback() const; + static GraphicFilter& GetGraphicFilter(); + static ErrCode LoadGraphic( const OUString& rPath, const OUString& rFilter, + Graphic& rGraphic, + GraphicFilter* pFilter = nullptr, + sal_uInt16* pDeterminedFormat = nullptr ); + + ErrCode compressAsPNG(const Graphic& rGraphic, SvStream& rOutputStream); + + void preload(); + +private: + OUString aFilterPath; + FilterConfigCache* pConfig; + + void ImplInit(); + ErrCode ImplSetError( ErrCode nError, const SvStream* pStm = nullptr ); + ErrCode ImpTestOrFindFormat( const OUString& rPath, SvStream& rStream, sal_uInt16& rFormat ); + + DECL_LINK( FilterCallback, ConvertData&, bool ); + + std::unique_ptr<FilterErrorEx> pErrorEx; + bool bUseConfig; +}; + +#endif // INCLUDED_VCL_GRAPHICFILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/graphictools.hxx b/include/vcl/graphictools.hxx new file mode 100644 index 000000000..90dcbc360 --- /dev/null +++ b/include/vcl/graphictools.hxx @@ -0,0 +1,369 @@ +/* -*- 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_GRAPHICTOOLS_HXX +#define INCLUDED_VCL_GRAPHICTOOLS_HXX + +#include <vcl/dllapi.h> +#include <sal/types.h> +#include <tools/color.hxx> +#include <tools/poly.hxx> +#include <vcl/graph.hxx> + +#include <vector> + +class SvStream; + +/** Encapsulates geometry and associated attributes of a graphical 'pen stroke' + + @attention Widespread use is deprecated. See declarations above + for the way to go. Especially the copied enums from svx/xenum.hxx + are troublesome. + + Use this class to store geometry and attributes of a graphical + 'pen stroke', such as pen width, dashing etc. The geometry is the + so-called 'path' along which the stroke is traced, with the given + pen width. The cap type determines how the open ends of the path + should be drawn. If the geometry consists of more than one + segment, the join type determines in which way the segments are + joined. + */ +class VCL_DLLPUBLIC SvtGraphicStroke +{ +public: + /// Style for open stroke ends + enum CapType + { + /// No additional cap + capButt=0, + /// Half-round cap at the line end, the center lying at the end point + capRound, + /// Half-square cap at the line end, the center lying at the end point + capSquare + }; + /// Style for joins of individual stroke segments + enum JoinType + { + /// Extend segment edges, until they cross + joinMiter=0, + /// Connect segments by a filled round arc + joinRound, + /// Connect segments by a direct straight line + joinBevel, + /// Perform no join, leads to visible gaps between thick line segments + joinNone + }; + typedef ::std::vector< double > DashArray; + + SvtGraphicStroke(); + /** All in one constructor + + See accessor method descriptions for argument description + */ + SvtGraphicStroke( const tools::Polygon& rPath, + const tools::PolyPolygon& rStartArrow, + const tools::PolyPolygon& rEndArrow, + double fTransparency, + double fStrokeWidth, + CapType aCap, + JoinType aJoin, + double fMiterLimit, + const DashArray& rDashArray ); // TODO: Dash array offset (position where to start, see PS) + + // accessors + /// Query path to stroke + void getPath ( tools::Polygon& ) const; + /** Get the polygon that is put at the start of the line + + The polygon is in a special normalized position: the center of + the stroked path will meet the given polygon at (0,0) from + negative y values. Thus, an arrow would have its baseline on + the x axis, going upwards to positive y values. Furthermore, + the polygon is also scaled in a special way: the width of the + joining stroke is defined to be + SvtGraphicStroke::normalizedArrowWidth (0x10000), i.e. ranging + from x=-0x8000 to x=0x8000. So, if the arrow does have this + width, it has to fit every stroke with every stroke width + exactly. + */ + void getStartArrow ( tools::PolyPolygon& ) const; + /** Get the polygon that is put at the end of the line + + The polygon is in a special normalized position, and already + scaled to the desired size: the center of the stroked path + will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + is also scaled in a special way: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. So, if the + arrow does have this width, it has to fit every stroke with + every stroke width exactly. + */ + void getEndArrow ( tools::PolyPolygon& ) const; + /** Get stroke transparency + + @return the transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + double getTransparency () const { return mfTransparency;} + /// Get width of the stroke + double getStrokeWidth () const { return mfStrokeWidth;} + /// Get the style in which open stroke ends are drawn + CapType getCapType () const { return maCapType;} + /// Get the style in which the stroke segments are joined + JoinType getJoinType () const { return maJoinType;} + /// Get the maximum length of mitered joins + double getMiterLimit () const { return mfMiterLimit;} + /// Get an array of "on" and "off" lengths for stroke dashing + void getDashArray ( DashArray& ) const; + + // mutators + /// Set path to stroke + void setPath ( const tools::Polygon& ); + /** Set the polygon that is put at the start of the line + + The polygon has to be in a special normalized position, and + already scaled to the desired size: the center of the stroked + path will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + also has to be scaled appropriately: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. If your + arrow does have this width, it will fit every stroke with + every stroke width exactly. + */ + void setStartArrow ( const tools::PolyPolygon& ); + /** Set the polygon that is put at the end of the line + + The polygon has to be in a special normalized position, and + already scaled to the desired size: the center of the stroked + path will meet the given polygon at (0,0) from negative y + values. Thus, an arrow would have its baseline on the x axis, + going upwards to positive y values. Furthermore, the polygon + also has to be scaled appropriately: the width of the joining + stroke is defined to be SvtGraphicStroke::normalizedArrowWidth + (0x10000), i.e. ranging from x=-0x8000 to x=0x8000. If your + arrow does have this width, it will fit every stroke with + every stroke width exactly. + */ + void setEndArrow ( const tools::PolyPolygon& ); + /// Affine scaling in both X and Y dimensions + void scale ( double fScaleX, double fScaleY ); + +private: + // friends + VCL_DLLPUBLIC friend SvStream& WriteSvtGraphicStroke( SvStream& rOStm, const SvtGraphicStroke& rClass ); + VCL_DLLPUBLIC friend SvStream& ReadSvtGraphicStroke( SvStream& rIStm, SvtGraphicStroke& rClass ); + + tools::Polygon maPath; + tools::PolyPolygon maStartArrow; + tools::PolyPolygon maEndArrow; + double mfTransparency; + double mfStrokeWidth; + CapType maCapType; + JoinType maJoinType; + double mfMiterLimit; + DashArray maDashArray; +}; + +/** Encapsulates geometry and associated attributes of a filled area + + @attention Widespread use is deprecated. See declarations above + for the way to go. Especially the copied enums from svx/xenum.hxx + is troublesome. + + Use this class to store geometry and attributes of a filled area, + such as fill color, transparency, texture or hatch. The geometry + is the so-called 'path', whose inner area will get filled + according to the attributes set. If the path is intersecting, or + one part of the path is lying fully within another part, then the + fill rule determines which parts are filled and which are not. + */ +class VCL_DLLPUBLIC SvtGraphicFill +{ +public: + /// Type of fill algorithm used + enum FillRule + { + /** Non-zero winding rule + + Fill shape scanline-wise. Starting at the left, determine + the winding number as follows: every segment crossed that + runs counter-clockwise adds one to the winding number, + every segment crossed that runs clockwise subtracts + one. The part of the scanline where the winding number is + non-zero gets filled. + */ + fillNonZero=0, + /** Even-odd fill rule + + Fill shape scanline-wise. Starting at the left, count the + number of segments crossed. If this number is odd, the + part of the scanline is filled, otherwise not. + */ + fillEvenOdd + }; + /// Type of filling used + enum FillType + { + /// Fill with a specified solid color + fillSolid=0, + /// Fill with the specified gradient + fillGradient, + /// Fill with the specified hatch + fillHatch, + /// Fill with the specified texture (a Graphic object) + fillTexture + }; + /// Type of hatching used + enum HatchType + { + /// horizontal parallel lines, one unit apart + hatchSingle=0, + /// horizontal and vertical orthogonally crossing lines, one unit apart + hatchDouble, + /// three crossing lines, like HatchType::hatchDouble, but + /// with an additional diagonal line, rising to the upper + /// right corner. The first diagonal line goes through the + /// upper left corner, the other are each spaced a unit apart. + hatchTriple + }; + /// Type of gradient used + enum class GradientType {Linear, Radial, Rectangular}; + /// Special values for gradient step count + enum { gradientStepsInfinite=0 }; + /** Homogeneous 2D transformation matrix + + This is a 2x3 matrix representing an affine transformation on + the R^2, in the usual C/C++ row major form. It is structured as follows: + <pre> + a b t_x + c d t_y + 0 0 1 + </pre> + where the lowest line is not stored in the matrix, since it is + constant. Variables t_x and t_y contain translational + components, a to d rotation, scale and shear (for details, + look up your favorite linear algebra/computer graphics book). + */ + struct VCL_DLLPUBLIC Transform + { + enum { MatrixSize=6 }; + Transform(); + double matrix[MatrixSize]; + }; + + SvtGraphicFill(); + /** All in one constructor + + See accessor method descriptions for argument description + */ + SvtGraphicFill( const tools::PolyPolygon& rPath, + Color aFillColor, + double fTransparency, + FillRule aFillRule, + FillType aFillType, // TODO: Multitexturing + const Transform& aFillTransform, + bool bTiling, + HatchType aHatchType, // TODO: vector of directions and start points + Color aHatchColor, + GradientType aGradientType, // TODO: Transparent gradients (orthogonal to normal ones) + Color aGradient1stColor, // TODO: vector of colors and offsets + Color aGradient2ndColor, + sal_Int32 aGradientStepCount, // numbers of steps to render the gradient. gradientStepsInfinite means infinitely many. + const Graphic& aFillGraphic ); + + // accessors + /// Query path to fill + void getPath ( tools::PolyPolygon& ) const; + /// Get color used for solid fills + const Color& getFillColor () const { return maFillColor;} + /** Get stroke transparency + + @return the transparency, ranging from 0.0 (opaque) to 1.0 (fully translucent) + */ + double getTransparency () const { return mfTransparency;} + /// Get fill rule used + FillRule getFillRule () const { return maFillRule;} + /** Get fill type used + + Currently, only one of the fill types can be used + simultaneously. If you specify e.g. FillRule::fillGradient, + hatching, texture and solid fill color are ignored. + */ + FillType getFillType () const { return maFillType;} + /** Get transformation applied to hatch, gradient or texture during fill + + A fill operation generally starts at the top left position of + the object's bounding box. At that position (if tiling is on, + also all successive positions), the specified fill graphic is + rendered, after applying the fill transformation to it. For + example, if the fill transformation contains a translation, + the fill graphic is rendered at the object's bounding box's + top left corner plus the translation components. + + */ + void getTransform ( Transform& ) const; + + /** Query state of texture tiling + + @return true, if texture is tiled, false, if output only once. + */ + bool isTiling () const { return mbTiling;} + /// Get type of gradient used + GradientType getGradientType () const { return maGradientType;} + + /** Get the texture graphic used + + The Graphic object returned is used to fill the geometry, if + the FillType is fillTexture. The Graphic object is always + assumed to be of size 1x1, the transformation is used to scale + it to the appropriate size. + */ + void getGraphic ( Graphic& ) const; + + // mutators + /// Set path to fill + void setPath ( const tools::PolyPolygon& rPath ); + +private: + // friends + VCL_DLLPUBLIC friend SvStream& WriteSvtGraphicFill( SvStream& rOStm, const SvtGraphicFill& rClass ); + VCL_DLLPUBLIC friend SvStream& ReadSvtGraphicFill( SvStream& rIStm, SvtGraphicFill& rClass ); + + tools::PolyPolygon maPath; + Color maFillColor; + double mfTransparency; + FillRule maFillRule; + FillType maFillType; + Transform maFillTransform; + bool mbTiling; + HatchType maHatchType; + Color maHatchColor; + GradientType maGradientType; + Color maGradient1stColor; + Color maGradient2ndColor; + sal_Int32 maGradientStepCount; + Graphic maFillGraphic; +}; + +#endif // INCLUDED_VCL_GRAPHICTOOLS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/hatch.hxx b/include/vcl/hatch.hxx new file mode 100644 index 000000000..c297e30fd --- /dev/null +++ b/include/vcl/hatch.hxx @@ -0,0 +1,77 @@ +/* -*- 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_HATCH_HXX +#define INCLUDED_VCL_HATCH_HXX + +#include <tools/color.hxx> +#include <vcl/dllapi.h> + +#include <vcl/vclenum.hxx> +#include <o3tl/cow_wrapper.hxx> + + +class SvStream; + +struct ImplHatch +{ + Color maColor; + HatchStyle meStyle; + long mnDistance; + sal_uInt16 mnAngle; + + ImplHatch(); + + bool operator==( const ImplHatch& rImplHatch ) const; +}; + +class VCL_DLLPUBLIC Hatch +{ +public: + + Hatch(); + Hatch( const Hatch& rHatch ); + Hatch( HatchStyle eStyle, const Color& rHatchColor, long nDistance, sal_uInt16 nAngle10 ); + ~Hatch(); + + Hatch& operator=( const Hatch& rHatch ); + bool operator==( const Hatch& rHatch ) const; + bool operator!=( const Hatch& rHatch ) const { return !(Hatch::operator==( rHatch ) ); } + + HatchStyle GetStyle() const { return mpImplHatch->meStyle; } + + void SetColor( const Color& rColor ); + const Color& GetColor() const { return mpImplHatch->maColor; } + + void SetDistance( long nDistance ); + long GetDistance() const { return mpImplHatch->mnDistance; } + + void SetAngle( sal_uInt16 nAngle10 ); + sal_uInt16 GetAngle() const { return mpImplHatch->mnAngle; } + + friend SvStream& ReadHatch( SvStream& rIStm, Hatch& rHatch ); + friend SvStream& WriteHatch( SvStream& rOStm, const Hatch& rHatch ); + +private: + o3tl::cow_wrapper< ImplHatch > mpImplHatch; +}; + +#endif // INCLUDED_VCL_HATCH_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/headbar.hxx b/include/vcl/headbar.hxx new file mode 100644 index 000000000..12d5c5941 --- /dev/null +++ b/include/vcl/headbar.hxx @@ -0,0 +1,320 @@ +/* -*- 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_HEADBAR_HXX +#define INCLUDED_VCL_HEADBAR_HXX + +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <vcl/window.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <memory> + +/************************************************************************* + +Description +============ + +class HeaderBar + +This class serves for displaying a header bar. A header bar can display +texts, images or both of them. The items can be changed in size, dragged or +clicked at. In many cases, it makes, for example, sense to use this control +in combination with a SvTabListBox. + +-------------------------------------------------------------------------- + +WinBits + +WB_BORDER a border is drawn in the top and in the bottom +WB_BOTTOMBORDER a border is drawn in the bottom +WB_BUTTONSTYLE The items look like buttons, otherwise they are flat. +WB_3DLOOK 3D look +WB_DRAG items can be dragged +WB_STDHEADERBAR WB_BUTTONSTYLE | WB_BOTTOMBORDER + +-------------------------------------------------------------------------- + +ItemBits + +HeaderBarItemBits::LEFT content is displayed in the item left-justified +HeaderBarItemBits::CENTER content is displayed in the item centred +HeaderBarItemBits::RIGHT content is displayed in the item right-justified +HeaderBarItemBits::TOP content is displayed in the item at the upper border +HeaderBarItemBits::VCENTER content is displayed in the item vertically centred +HeaderBarItemBits::BOTTOM content is displayed in the item at the bottom border +HeaderBarItemBits::LEFTIMAGE in case of text and image, the image is displayed left of the text +HeaderBarItemBits::RIGHTIMAGE in case of text and image, the image is displayed right of the text +HeaderBarItemBits::FIXED item cannot be changed in size +HeaderBarItemBits::FIXEDPOS item cannot be moved +HeaderBarItemBits::CLICKABLE item is clickable + (select handler is only called on MouseButtonUp) +HeaderBarItemBits::FLAT item is displayed in a flat way, even if WB_BUTTONSTYLE is set +HeaderBarItemBits::DOWNARROW An arrow pointing downwards is displayed behind the text, + which should, for example, be shown, when after this item, + a corresponding list is sorted in descending order. + The status of the arrow can be set/reset with SetItemBits(). +HeaderBarItemBits::UPARROW An arrow pointing upwards is displayed behind the text, + which should, for example, be shown, when after this item, + a corresponding list is sorted in ascending order. + The status of the arrow can be set/reset with SetItemBits(). +HeaderBarItemBits::USERDRAW For this item, the UserDraw handler is called as well. +HeaderBarItemBits::STDSTYLE (HeaderBarItemBits::LEFT | HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::CLICKABLE) + +-------------------------------------------------------------------------- + +Handler + +Select() Is called, when the item is clicked. If HeaderBarItemBits::CLICKABLE + is set in the item and not HeaderBarItemBits::FLAT, the handler is only + called in the MouseButtonUp handler, when the mouse has been + released over the item. In this case, the Select handler + behaves like it does with a ToolBox button. +DoubleClick() This handler is called, when an item is double-clicked. + Whether the item or the separator has been clicked, can + be determined by IsItemMode(). Normally, when a separator + is double-clicked, the optimal column width should be + calculated and should be set. +StartDrag() This handler is called, when dragging is started resp. + an item has been clicked. At the latest in this handler, + the size of the size-line should be set with + SetDragSize(), if IsItemMode() returns false. +Drag() This handler is called, when dragging is taking place. + If no size is set with SetDragSize(), this handler can + be used to draw the line in the neighbouring window by + oneself. The current dragging position can be requested + with GetDragPos(). In every case, IsItemMode() + should be checked to find out whether a separator is + dragged as well. +EndDrag() This handler is called, when a dragging process has been + stopped. If GetCurItemId() returns 0 in the EndDrag handler, + the drag process was aborted. If this is not the case and + IsItemMode() returns false, the new size of the dragged + item should be requested using GetItemSize() and it + should be taken over in the corresponding control. + If IsItemMode() returns true, GetCurItemId() + returns an Id and IsItemDrag() returns true, this + item has been dragged. In this case, the new position + should be requested using GetItemPos() and the data + in the corresponding control should be adapted. + Otherwise, the position to which the item has been dragged + could also be requested with GetItemDragPos(). + +Further methods that are important for the handler. + +GetCurItemId() Returns the id of the item, for which the handler has + currently been called. Only returns a valid id in the + handlers Select(), DoubleClick(), StartDrag(), + Drag() and EndDrag(). In the EndDrag handler, + this method returns the id of the dragged item or 0, + if the drag process has been aborted. +GetItemDragPos() Returns the position, at which an item has been moved. + HEADERBAR_ITEM_NOTFOUND is returned, if the process + has been aborted or no ItemDrag is active. +IsItemMode() This method can be used to determine whether the + handler has been called for an item or a separator. + true - handler was called for the item + false - handler was called for the separator +IsItemDrag() This method can be used to determine whether an item + has been dragged or selected. + true - item is dragged + false - item is selected +SetDragSize() This method is used to set the size of the separating + line that is drawn by the control. It should be + equivalent to the height of the neighbouring window. + The height of the HeaderBar is added automatically. + +-------------------------------------------------------------------------- + +Further methods + +SetOffset() This method sets the offset, from which on the + items are shown. This is needed when the + corresponding window is scrolled. +CalcWindowSizePixel() This method can be used to calculate the height + of the window, so that the content of the item + can be displayed. + +-------------------------------------------------------------------------- + +Tips and tricks: + +1) ContextMenu +If a context sensitive PopupMenu should be shown, the command +handler must be overlaid. Using GetItemId() and when passing the +mouse position, it can be determined whether the mouse click has been +carried out over an item resp. over which item the mouse click has been +carried out. + +2) last item +If ButtonStyle has been set, it looks better, if an empty item is +set at the end which takes up the remaining space. +In order to do that, you can insert an item with an empty string and +pass HEADERBAR_FULLSIZE as size. For such an item, you should not set +HeaderBarItemBits::CLICKABLE, but HeaderBarItemBits::FIXEDPOS. + +*************************************************************************/ + +class ImplHeadItem; + +#define WB_BOTTOMBORDER (WinBits(0x0400)) +#define WB_BUTTONSTYLE (WinBits(0x0800)) +#define WB_STDHEADERBAR (WB_BUTTONSTYLE | WB_BOTTOMBORDER) + +enum class HeaderBarItemBits +{ + NONE = 0x0000, + LEFT = 0x0001, + CENTER = 0x0002, + RIGHT = 0x0004, + LEFTIMAGE = 0x0010, + RIGHTIMAGE = 0x0020, + CLICKABLE = 0x0400, + FLAT = 0x0800, + DOWNARROW = 0x1000, + UPARROW = 0x2000, + STDSTYLE = LEFT | LEFTIMAGE | CLICKABLE, +}; + +namespace o3tl +{ + template<> struct typed_flags<HeaderBarItemBits> : is_typed_flags<HeaderBarItemBits, 0x3c37> {}; +} + +#define HEADERBAR_APPEND (sal_uInt16(0xFFFF)) +#define HEADERBAR_ITEM_NOTFOUND (sal_uInt16(0xFFFF)) +#define HEADERBAR_FULLSIZE (long(1000000000)) + +class VCL_DLLPUBLIC HeaderBar : public vcl::Window +{ +private: + std::vector<std::unique_ptr<ImplHeadItem>> mvItemList; + long mnBorderOff1; + long mnBorderOff2; + long mnOffset; + long mnDX; + long mnDY; + long mnDragSize; + long mnStartPos; + long mnDragPos; + long mnMouseOff; + sal_uInt16 mnCurItemId; + sal_uInt16 mnItemDragPos; + bool mbDragable; + bool mbDrag; + bool mbItemDrag; + bool mbOutDrag; + bool mbButtonStyle; + bool mbItemMode; + Link<HeaderBar*,void> maStartDragHdl; + Link<HeaderBar*,void> maEndDragHdl; + Link<HeaderBar*,void> maSelectHdl; + Link<HeaderBar*,void> maCreateAccessibleHdl; + + css::uno::Reference< css::accessibility::XAccessible > + mxAccessible; + + using Window::ImplInit; + VCL_DLLPRIVATE void ImplInit( WinBits nWinStyle ); + VCL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); + VCL_DLLPRIVATE long ImplGetItemPos( sal_uInt16 nPos ) const; + VCL_DLLPRIVATE tools::Rectangle ImplGetItemRect( sal_uInt16 nPos ) const; + using Window::ImplHitTest; + VCL_DLLPRIVATE sal_uInt16 ImplHitTest( const Point& rPos, long& nMouseOff, sal_uInt16& nPos ) const; + VCL_DLLPRIVATE void ImplInvertDrag( sal_uInt16 nStartPos, sal_uInt16 nEndPos ); + VCL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHigh, + const tools::Rectangle& rItemRect, const tools::Rectangle* pRect); + VCL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, sal_uInt16 nPos, bool bHigh, + const tools::Rectangle* pRect); + VCL_DLLPRIVATE void ImplUpdate( sal_uInt16 nPos, + bool bEnd = false ); + VCL_DLLPRIVATE void ImplStartDrag( const Point& rPos, bool bCommand ); + VCL_DLLPRIVATE void ImplDrag( const Point& rPos ); + VCL_DLLPRIVATE void ImplEndDrag( bool bCancel ); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + HeaderBar( vcl::Window* pParent, WinBits nWinBits ); + virtual ~HeaderBar() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual Size GetOptimalSize() const override; + + virtual void EndDrag(); + virtual void Select(); + virtual void DoubleClick(); + + void InsertItem( sal_uInt16 nItemId, const OUString& rText, + long nSize, HeaderBarItemBits nBits = HeaderBarItemBits::STDSTYLE, + sal_uInt16 nPos = HEADERBAR_APPEND ); + void RemoveItem( sal_uInt16 nItemId ); + void MoveItem( sal_uInt16 nItemId, sal_uInt16 nNewPos ); + void Clear(); + + void SetOffset( long nNewOffset ); + void SetDragSize( long nNewSize ) { mnDragSize = nNewSize; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + tools::Rectangle GetItemRect( sal_uInt16 nItemId ) const; + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + bool IsItemMode() const { return mbItemMode; } + + void SetItemSize( sal_uInt16 nItemId, long nNewSize ); + long GetItemSize( sal_uInt16 nItemId ) const; + void SetItemBits( sal_uInt16 nItemId, HeaderBarItemBits nNewBits ); + HeaderBarItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetItemText( sal_uInt16 nItemId, const OUString& rText ); + OUString GetItemText( sal_uInt16 nItemId ) const; + + OUString GetHelpText( sal_uInt16 nItemId ) const; + + Size CalcWindowSizePixel() const; + + using Window::SetHelpId; + + void SetStartDragHdl( const Link<HeaderBar*,void>& rLink ) { maStartDragHdl = rLink; } + void SetEndDragHdl( const Link<HeaderBar*,void>& rLink ) { maEndDragHdl = rLink; } + void SetSelectHdl( const Link<HeaderBar*,void>& rLink ) { maSelectHdl = rLink; } + void SetCreateAccessibleHdl( const Link<HeaderBar*,void>& rLink ) { maCreateAccessibleHdl = rLink; } + + bool IsDragable() const { return mbDragable; } + + /** Creates and returns the accessible object of the header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + void SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& ); +}; + +#endif // INCLUDED_VCL_HEADBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/help.hxx b/include/vcl/help.hxx new file mode 100644 index 000000000..83b2bdbe5 --- /dev/null +++ b/include/vcl/help.hxx @@ -0,0 +1,113 @@ +/* -*- 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_HELP_HXX +#define INCLUDED_VCL_HELP_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <o3tl/typed_flags_set.hxx> + +class Point; +namespace tools { class Rectangle; } +namespace vcl { class Window; } + + +enum class QuickHelpFlags +{ + NONE = 0x0000, + Left = 0x0001, + Center = 0x0002, + Right = 0x0004, + Top = 0x0008, + VCenter = 0x0010, + Bottom = 0x0020, + NoAutoPos = Left | Center | Right | Top | VCenter | Bottom, + CtrlText = 0x0040, +/// force balloon-style in ShowPopover and ShowQuickHelp + TipStyleBalloon = 0x0100, + NoEvadePointer = 0x0200, + BiDiRtl = 0x0400, +}; +namespace o3tl +{ + template<> struct typed_flags<QuickHelpFlags> : is_typed_flags<QuickHelpFlags, 0x77f> {}; +} + +#define OOO_HELP_INDEX ".help:index" + +namespace weld +{ + class Widget; +} + +class VCL_DLLPUBLIC Help +{ +public: + Help(); + virtual ~Help(); + + virtual bool Start(const OUString& rHelpId, const vcl::Window* pWindow); + virtual bool Start(const OUString& rHelpId, weld::Widget* pWidget); + virtual void SearchKeyword( const OUString& rKeyWord ); + virtual OUString GetHelpText(const OUString& aHelpURL, const vcl::Window* pWindow); + virtual OUString GetHelpText(const OUString& aHelpURL, const weld::Widget* pWidget); + + static void EnableContextHelp(); + static void DisableContextHelp(); + static bool IsContextHelpEnabled(); + + static void EnableExtHelp(); + static void DisableExtHelp(); + static bool IsExtHelpEnabled(); + static bool StartExtHelp(); + static bool EndExtHelp(); + + static void EnableBalloonHelp(); + static void DisableBalloonHelp(); + static bool IsBalloonHelpEnabled(); + static void ShowBalloon( vcl::Window* pParent, + const Point& rScreenPos, + const tools::Rectangle&, + const OUString& rHelpText ); + + static void EnableQuickHelp(); + static void DisableQuickHelp(); + static bool IsQuickHelpEnabled(); + static void ShowQuickHelp( vcl::Window* pParent, + const tools::Rectangle& rScreenRect, + const OUString& rHelpText, + QuickHelpFlags nStyle = QuickHelpFlags::NONE ); + + static void HideBalloonAndQuickHelp(); + + static void* ShowPopover(vcl::Window* pParent, + const tools::Rectangle& rScreenRect, + const OUString& rText, + QuickHelpFlags nStyle); + static void UpdatePopover(void* nId, + vcl::Window* pParent, + const tools::Rectangle& rScreenRect, + const OUString& rText); + static void HidePopover(vcl::Window const * pParent, void* nId); +}; + +#endif // INCLUDED_VCL_HELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/i18nhelp.hxx b/include/vcl/i18nhelp.hxx new file mode 100644 index 000000000..38d0232b2 --- /dev/null +++ b/include/vcl/i18nhelp.hxx @@ -0,0 +1,82 @@ +/* -*- 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_I18NHELP_HXX +#define INCLUDED_VCL_I18NHELP_HXX + +#include <com/sun/star/uno/Reference.h> +#include <i18nlangtag/languagetag.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <memory> + +namespace com { +namespace sun { +namespace star { +namespace uno { + class XComponentContext; +} +}}} + +namespace utl { + class TransliterationWrapper; +} + +class LocaleDataWrapper; + +namespace vcl +{ + +class VCL_DLLPUBLIC I18nHelper +{ + ::osl::Mutex maMutex; + LanguageTag maLanguageTag; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; + std::unique_ptr<utl::TransliterationWrapper> mpTransliterationWrapper; + + bool mbTransliterateIgnoreCase; + + SAL_DLLPRIVATE void ImplDestroyWrappers(); + + SAL_DLLPRIVATE utl::TransliterationWrapper& ImplGetTransliterationWrapper() const; + SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const; + +public: + + I18nHelper( const css::uno::Reference< css::uno::XComponentContext >& rxContext, const LanguageTag& rLanguageTag ); + ~I18nHelper(); + + sal_Int32 CompareString( const OUString& rStr1, const OUString& rStr2 ) const; + + bool MatchString( const OUString& rStr1, const OUString& rStr2 ) const; + bool MatchMnemonic( const OUString& rString, sal_Unicode cMnemonicChar ) const; + + OUString GetNum( long nNumber, sal_uInt16 nDecimals, bool bUseThousandSep = true, bool bTrailingZeros = true ) const; + + static OUString filterFormattingChars( const OUString& ); +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_I18NHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx new file mode 100644 index 000000000..ebbeb160c --- /dev/null +++ b/include/vcl/idle.hxx @@ -0,0 +1,66 @@ +/* -*- 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_IDLE_HXX +#define INCLUDED_VCL_IDLE_HXX + +#include <vcl/timer.hxx> + +/** + * An idle is a timer to be scheduled immediately. + * + * It's - more or less - just a convenience class. + */ +class VCL_DLLPUBLIC Idle : public Timer +{ +private: + // Delete all timeout specific functions, we don't want in an Idle + void SetTimeout( sal_uInt64 nTimeoutMs ) = delete; + sal_uInt64 GetTimeout() const = delete; + +protected: + virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nTimeNow ) const override; + + Idle( bool bAuto, const char *pDebugName ); + +public: + Idle( const char *pDebugName = nullptr ); + + virtual void Start() override; +}; + +/** + * An auto-idle is long running task processing small chunks of data, which + * is re-scheduled multiple times. + * + * Remember to stop the Idle when finished, as it would otherwise busy loop the CPU! + * + * It probably makes sense to re-implement ReadyForSchedule and UpdateMinPeriod, + * in case there is a quick check and it can otherwise sleep. + */ +class VCL_DLLPUBLIC AutoIdle : public Idle +{ +public: + AutoIdle( const char *pDebugName ); +}; + + +#endif // INCLUDED_VCL_IDLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/image.hxx b/include/vcl/image.hxx new file mode 100644 index 000000000..f01c17472 --- /dev/null +++ b/include/vcl/image.hxx @@ -0,0 +1,76 @@ +/* -*- 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_IMAGE_HXX +#define INCLUDED_VCL_IMAGE_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/outdev.hxx> + +#include <memory> + +class ImplImage; + +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::uno { template <class interface_type> class Reference; } + +#define IMAGELIST_IMAGE_NOTFOUND (sal_uInt16(0xFFFF)) + +enum class StockImage { Yes }; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC Image +{ + friend class ::OutputDevice; +public: + Image(); + explicit Image(BitmapEx const & rBitmapEx); + explicit Image(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic); + explicit Image(OUString const & rPNGFileUrl); + explicit Image(StockImage, OUString const & rPNGFilePath, Size aSpecificSize = Size()); + + Size GetSizePixel() const; + BitmapEx GetBitmapEx() const; + + bool operator!() const + { + return !mpImplData; + } + bool operator==(const Image& rImage) const; + bool operator!=(const Image& rImage) const + { + return !(Image::operator==(rImage)); + } + + OUString GetStock() const; + + void Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle, const Size* pSize = nullptr); + +private: + + std::shared_ptr<ImplImage> mpImplData; + + SAL_DLLPRIVATE void ImplInit(BitmapEx const & rBmpEx); +}; + +#endif // INCLUDED_VCL_IMAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/imap.hxx b/include/vcl/imap.hxx new file mode 100644 index 000000000..5cf03071b --- /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 <vcl/imapobj.hxx> +#include <vcl/dllapi.h> +#include <tools/stream.hxx> +#include <tools/solar.h> +#include <memory> +#include <vector> + +class Point; +class Size; +class Fraction; +class IMapObject; + +class VCL_DLLPUBLIC ImageMap final +{ +private: + + std::vector<std::unique_ptr<IMapObject>> 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<IMapObject> 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 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 000000000..11e369d09 --- /dev/null +++ b/include/vcl/imapcirc.hxx @@ -0,0 +1,70 @@ +/* -*- 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 <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <tools/solar.h> +#include <vcl/imapobj.hxx> + +class Fraction; + +class VCL_DLLPUBLIC IMapCircleObject final : public IMapObject +{ + Point aCenter; + sal_Int32 nRadius; + + void ImpConstruct( const Point& rCenter, sal_uLong nRad, bool bPixel ); + + // 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 000000000..231032890 --- /dev/null +++ b/include/vcl/imapobj.hxx @@ -0,0 +1,124 @@ +/* -*- 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 <vcl/dllapi.h> +#include <svl/macitem.hxx> +#include <rtl/strbuf.hxx> + +class Point; +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 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: + + 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 000000000..7bf48b6d5 --- /dev/null +++ b/include/vcl/imappoly.hxx @@ -0,0 +1,73 @@ +/* -*- 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 <vcl/dllapi.h> +#include <vcl/imapobj.hxx> +#include <tools/poly.hxx> + +class Fraction; + +class VCL_DLLPUBLIC IMapPolygonObject final : public IMapObject +{ + tools::Polygon aPoly; + tools::Rectangle aEllipse; + bool bEllipse; + + VCL_DLLPRIVATE void ImpConstruct( const tools::Polygon& rPoly, bool bPixel ); + + // 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 000000000..9f9ab842a --- /dev/null +++ b/include/vcl/imaprect.hxx @@ -0,0 +1,67 @@ +/* -*- 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 <vcl/dllapi.h> +#include <vcl/imapobj.hxx> +#include <tools/gen.hxx> + +class Fraction; + +class VCL_DLLPUBLIC IMapRectangleObject final : public IMapObject +{ + tools::Rectangle aRect; + + VCL_DLLPRIVATE void ImpConstruct( const tools::Rectangle& rRect, bool bPixel ); + + // 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 000000000..64d64c122 --- /dev/null +++ b/include/vcl/inetimg.hxx @@ -0,0 +1,58 @@ +/* -*- 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 <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <sot/formats.hxx> + + +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/inputctx.hxx b/include/vcl/inputctx.hxx new file mode 100644 index 000000000..25d057b91 --- /dev/null +++ b/include/vcl/inputctx.hxx @@ -0,0 +1,81 @@ +/* -*- 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_INPUTCTX_HXX +#define INCLUDED_VCL_INPUTCTX_HXX + +#include <vcl/dllapi.h> +#include <vcl/font.hxx> +#include <o3tl/typed_flags_set.hxx> + + +enum class InputContextFlags +{ + NONE = 0x0000, + Text = 0x0001, + ExtText = 0x0002 +}; +namespace o3tl +{ + template<> struct typed_flags<InputContextFlags> : is_typed_flags<InputContextFlags, 0x0003> {}; +} + + +class VCL_DLLPUBLIC InputContext +{ +private: + vcl::Font maFont; + InputContextFlags mnOptions; + +public: + InputContext() { mnOptions = InputContextFlags::NONE; } + InputContext( const InputContext& rInputContext ) : + maFont( rInputContext.maFont ) + { mnOptions = rInputContext.mnOptions; } + InputContext( const vcl::Font& rFont, InputContextFlags nOptions = InputContextFlags::NONE ) : + maFont( rFont ) + { mnOptions = nOptions; } + + const vcl::Font& GetFont() const { return maFont; } + + void SetOptions( InputContextFlags nOptions ) { mnOptions = nOptions; } + InputContextFlags GetOptions() const { return mnOptions; } + + InputContext& operator=( const InputContext& rInputContext ); + bool operator==( const InputContext& rInputContext ) const; + bool operator!=( const InputContext& rInputContext ) const + { return !(InputContext::operator==( rInputContext )); } +}; + +inline InputContext& InputContext::operator=( const InputContext& rInputContext ) +{ + maFont = rInputContext.maFont; + mnOptions = rInputContext.mnOptions; + return *this; +} + +inline bool InputContext::operator==( const InputContext& rInputContext ) const +{ + return ((mnOptions == rInputContext.mnOptions) && + (maFont == rInputContext.maFont)); +} + +#endif // INCLUDED_VCL_INPUTCTX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/inputtypes.hxx b/include/vcl/inputtypes.hxx new file mode 100644 index 000000000..c5805084b --- /dev/null +++ b/include/vcl/inputtypes.hxx @@ -0,0 +1,43 @@ +/* -*- 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_INPUTTYPES_HXX +#define INCLUDED_VCL_INPUTTYPES_HXX + +#include <o3tl/typed_flags_set.hxx> + +enum class VclInputFlags { + NONE = 0x0000, + MOUSE = 0x0001, + KEYBOARD = 0x0002, + PAINT = 0x0004, + TIMER = 0x0008, + OTHER = 0x0010, + APPEVENT = 0x0020, +}; +namespace o3tl +{ + template<> struct typed_flags<VclInputFlags> : is_typed_flags<VclInputFlags, 0x003f> {}; +} + +#define VCL_INPUT_ANY (VclInputFlags::MOUSE | VclInputFlags::KEYBOARD | VclInputFlags::PAINT | VclInputFlags::TIMER | VclInputFlags::OTHER | VclInputFlags::APPEVENT) + +#endif // INCLUDED_VCL_INPUTTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/introwin.hxx b/include/vcl/introwin.hxx new file mode 100644 index 000000000..fbe35c710 --- /dev/null +++ b/include/vcl/introwin.hxx @@ -0,0 +1,41 @@ +/* -*- 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_INTROWIN_HXX +#define INCLUDED_VCL_INTROWIN_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/wrkwin.hxx> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) IntroWindow : public WorkWindow +{ +private: + SAL_DLLPRIVATE void ImplInitIntroWindowData(); + +public: + IntroWindow(); + virtual ~IntroWindow() override; + virtual void dispose() override; + +}; + +#endif // INCLUDED_VCL_INTROWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ivctrl.hxx b/include/vcl/ivctrl.hxx new file mode 100644 index 000000000..adadcc9fe --- /dev/null +++ b/include/vcl/ivctrl.hxx @@ -0,0 +1,330 @@ +/* -*- 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_IVCTRL_HXX +#define INCLUDED_VCL_IVCTRL_HXX + +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/layout.hxx> +#include <tools/link.hxx> +#include <vcl/image.hxx> +#include <o3tl/deleter.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SvxIconChoiceCtrl_Impl; + +enum class SvxIconViewFlags +{ + NONE = 0x0000, + POS_LOCKED = 0x0001, + SELECTED = 0x0002, + FOCUSED = 0x0004, + POS_MOVED = 0x0008, // Moved by Drag and Drop, but not logged +}; +namespace o3tl +{ + template<> struct typed_flags<SvxIconViewFlags> : is_typed_flags<SvxIconViewFlags, 0x000f> {}; +} + +enum class SvxIconChoiceCtrlTextMode +{ + Full = 1, // Enlarge BoundRect southwards + Short // Shorten with "..." +}; + +enum class SvxIconChoiceCtrlPositionMode +{ + Free, // Free pixel-perfect positioning + AutoArrange, // Auto arrange +}; + +class SvxIconChoiceCtrlEntry +{ + Image aImage; + + OUString aText; + OUString aQuickHelpText; + void* pUserData; + + friend class SvxIconChoiceCtrl_Impl; + friend class IcnCursor_Impl; + friend class EntryList_Impl; + friend class IcnGridMap_Impl; + + tools::Rectangle aRect; // Bounding-Rectangle of the entry + tools::Rectangle aGridRect; // Only valid in Grid-mode + sal_Int32 nPos; + + /* + The insert position in the Insertlist is equal to the (sort) order stated at the Insert + (-> Order of the anchors in the anchors-list!). In "AutoArrange" mode the visible order + can differ. The entries will be linked because of this. + */ + SvxIconChoiceCtrlEntry* pblink; // backward (linker neighbour) + SvxIconChoiceCtrlEntry* pflink; // forward (rechter neighbour) + + SvxIconChoiceCtrlTextMode eTextMode; + sal_uInt16 nX,nY; // for keyboard control + SvxIconViewFlags nFlags; + + void ClearFlags( SvxIconViewFlags nMask ) { nFlags &= ~nMask; } + void SetFlags( SvxIconViewFlags nMask ) { nFlags |= nMask; } + void AssignFlags( SvxIconViewFlags _nFlags ) { nFlags = _nFlags; } + + // set left neighbour (A <-> B ==> A <-> this <-> B) + void SetBacklink( SvxIconChoiceCtrlEntry* pA ) + { + pA->pflink->pblink = this; // X <- B + this->pflink = pA->pflink; // X -> B + this->pblink = pA; // A <- X + pA->pflink = this; // A -> X + } + // Unlink (A <-> this <-> B ==> A <-> B) + void Unlink() + { + this->pblink->pflink = this->pflink; + this->pflink->pblink = this->pblink; + this->pflink = nullptr; + this->pblink = nullptr; + } + +public: + SvxIconChoiceCtrlEntry( const OUString& rText, const Image& rImage ); + + const Image& GetImage () const { return aImage; } + void SetText ( const OUString& rText ) { aText = rText; } + const OUString& GetText () const { return aText; } + OUString VCL_DLLPUBLIC GetDisplayText() const; + void SetQuickHelpText( const OUString& rText ) { aQuickHelpText = rText; } + const OUString& GetQuickHelpText() const { return aQuickHelpText; } + void SetUserData ( void* _pUserData ) { pUserData = _pUserData; } + void* GetUserData () { return pUserData; } + + SvxIconChoiceCtrlTextMode GetTextMode() const { return eTextMode; } + SvxIconViewFlags GetFlags() const { return nFlags; } + bool IsSelected() const { return bool(nFlags & SvxIconViewFlags::SELECTED); } + bool IsFocused() const { return bool(nFlags & SvxIconViewFlags::FOCUSED); } + bool IsPosLocked() const { return bool(nFlags & SvxIconViewFlags::POS_LOCKED); } +}; + +class SvxIconChoiceCtrlColumnInfo +{ + long nWidth; + +public: + SvxIconChoiceCtrlColumnInfo() : + nWidth( 100 ) {} + SvxIconChoiceCtrlColumnInfo( const SvxIconChoiceCtrlColumnInfo& ); + + void SetWidth( long nWd ) { nWidth = nWd; } + long GetWidth() const { return nWidth; } +}; + + +/* + Window-Bits: + WB_ICON // Text beneath the icon + WB_SMALL_ICON // Text right to the icon, position does not mind + WB_DETAILS // Text right to the icon, limited positioning + WB_BORDER + WB_NOHIDESELECTION // Draw selection inactively, if not focused. + WB_NOHSCROLL + WB_NOVSCROLL + WB_NOSELECTION + WB_SMART_ARRANGE // Keep Visible-Area at arrange + WB_ALIGN_TOP // Align line vy line LTR + WB_ALIGN_LEFT // Align columns from top to bottom + WB_NODRAGSELECTION // No selection with tracking rectangle + WB_NOCOLUMNHEADER // No Headerbar in Details view (Headerbar not implemented) + WB_NOPOINTERFOCUS // No GrabFocus at MouseButtonDown + WB_HIGHLIGHTFRAME // The entry beneath the mouse will be highlighted + WB_NOASYNCSELECTHDL // Do not collect events -> Selection handlers will be called synchronously +*/ + +#define WB_ICON WB_RECTSTYLE +#define WB_SMALLICON WB_SMALLSTYLE +#define WB_DETAILS WB_VCENTER +#define WB_NOHSCROLL WB_SPIN +#define WB_NOVSCROLL WB_DRAG +#define WB_NOSELECTION WB_REPEAT +#define WB_NODRAGSELECTION WB_PATHELLIPSIS +#define WB_SMART_ARRANGE 0x01000000 // used to be WB_PASSWORD +#define WB_ALIGN_TOP WB_TOP +#define WB_ALIGN_LEFT WB_LEFT +#define WB_NOCOLUMNHEADER WB_CENTER +#define WB_HIGHLIGHTFRAME WB_IGNORETAB +#define WB_NOASYNCSELECTHDL WB_NOLABEL + +class MnemonicGenerator; + +class VCL_DLLPUBLIC SvtIconChoiceCtrl : public Control +{ + friend class SvxIconChoiceCtrl_Impl; + + Link<SvtIconChoiceCtrl*,void> _aClickIconHdl; + std::unique_ptr<SvxIconChoiceCtrl_Impl, o3tl::default_delete<SvxIconChoiceCtrl_Impl>> _pImpl; + +protected: + + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + 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 Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + void ClickIcon(); + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + static void DrawEntryImage( + SvxIconChoiceCtrlEntry const * pEntry, + const Point& rPos, + OutputDevice& rDev ); + + static OUString GetEntryText( SvxIconChoiceCtrlEntry const * pEntry ); + + virtual void FillLayoutData() const override; + + void CallImplEventListeners(VclEventId nEvent, void* pData); + +public: + + SvtIconChoiceCtrl( vcl::Window* pParent, WinBits nWinStyle ); + virtual ~SvtIconChoiceCtrl() override; + virtual void dispose() override; + + WinBits GetStyle() const; + + void SetChoiceWithCursor(); + + void SetFont( const vcl::Font& rFont ); + void SetPointFont( const vcl::Font& rFont ); + + void SetClickHdl( const Link<SvtIconChoiceCtrl*,void>& rLink ) { _aClickIconHdl = rLink; } + const Link<SvtIconChoiceCtrl*,void>& GetClickHdl() const { return _aClickIconHdl; } + + using OutputDevice::SetBackground; + void SetBackground( const Wallpaper& rWallpaper ); + + void ArrangeIcons(); + + + SvxIconChoiceCtrlEntry* InsertEntry( const OUString& rText, + const Image& rImage); + + void RemoveEntry(sal_Int32 nEntryListPos); + + /** creates automatic mnemonics for all icon texts in the control + + @param _rUsedMnemonics + a MnemonicGenerator at which some other mnemonics are already registered. + This can be used if the control needs to share the "mnemonic space" with other elements, + such as a menu bar. + */ + void CreateAutoMnemonics( MnemonicGenerator& _rUsedMnemonics ); + + bool DoKeyInput( const KeyEvent& rKEvt ); + + sal_Int32 GetEntryCount() const; + SvxIconChoiceCtrlEntry* GetEntry( sal_Int32 nPos ) const; + sal_Int32 GetEntryListPos( SvxIconChoiceCtrlEntry const * pEntry ) const; + using Window::SetCursor; + void SetCursor( SvxIconChoiceCtrlEntry* pEntry ); + SvxIconChoiceCtrlEntry* GetCursor() const; + + // Re-calculation of cached view-data and invalidation of those in the view + void InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry ); + + // Entry is selected, if the BoundRect is selected + SvxIconChoiceCtrlEntry* GetEntry( const Point& rPosPixel ) const; + + // sal_uLong is the position of the selected element in the list + SvxIconChoiceCtrlEntry* GetSelectedEntry() const; + +#ifdef DBG_UTIL + void SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode, SvxIconChoiceCtrlEntry* pEntry ); +#endif + + void SetSelectionMode( SelectionMode eMode ); + + tools::Rectangle GetBoundingBox( SvxIconChoiceCtrlEntry* pEntry ) const; + tools::Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const; + + void SetNoSelection(); + + // ACCESSIBILITY ========================================================== + + /** Creates and returns the accessible object of the Box. */ + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; +}; + +struct VerticalTabPageData; + +class VerticalTabControl final : public VclHBox +{ + VclPtr<SvtIconChoiceCtrl> m_xChooser; + VclPtr<VclVBox> m_xBox; + + std::vector<std::unique_ptr<VerticalTabPageData>> maPageList; + OString m_sCurrentPageId; + + Link<VerticalTabControl*,void> m_aActivateHdl; + Link<VerticalTabControl*,bool> m_aDeactivateHdl; + + DECL_LINK(ChosePageHdl_Impl, SvtIconChoiceCtrl*, void); + + void ActivatePage(); + bool DeactivatePage(); + + VerticalTabPageData* GetPageData(const OString& rId) const; + VerticalTabPageData* GetPageData(const SvxIconChoiceCtrlEntry* pEntry) const; + +public: + VerticalTabControl(vcl::Window* pParent); + virtual ~VerticalTabControl() override; + virtual void dispose() override; + + sal_uInt16 GetPageCount() const { return m_xChooser->GetEntryCount(); } + + OString GetCurPageId() const { return m_sCurrentPageId; } + void SetCurPageId(const OString& rId); + + sal_uInt16 GetPagePos(const OString& rPageId) const; + OString GetPageId(sal_uInt16 nIndex) const; + VclPtr<vcl::Window> GetPage(const OString& rPageId); + + void RemovePage(const OString& rPageId); + void InsertPage(const OString& rPageId, const OUString& rLabel, const Image& rImage, const OUString& rTooltip, VclPtr<vcl::Window> xPage, int nPos = -1); + + void SetActivatePageHdl( const Link<VerticalTabControl*,void>& rLink ) { m_aActivateHdl = rLink; } + void SetDeactivatePageHdl( const Link<VerticalTabControl*, bool>& rLink ) { m_aDeactivateHdl = rLink; } + + OUString GetPageText(const OString& rPageId) const; + void SetPageText(const OString& rPageId, const OUString& rText); + + vcl::Window* GetPageParent() { return m_xBox.get(); } +}; + +#endif // INCLUDED_VCL_IVCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/jobset.hxx b/include/vcl/jobset.hxx new file mode 100644 index 000000000..ff7b5dfb6 --- /dev/null +++ b/include/vcl/jobset.hxx @@ -0,0 +1,63 @@ +/* -*- 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_JOBSET_HXX +#define INCLUDED_VCL_JOBSET_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <o3tl/cow_wrapper.hxx> + +class SvStream; +class ImplJobSetup; + +class VCL_DLLPUBLIC JobSetup +{ + friend class Printer; + +public: + JobSetup(); + JobSetup( const JobSetup& rJob ); + ~JobSetup(); + + JobSetup& operator=( const JobSetup& rJob ); + JobSetup& operator=( JobSetup&& rJob ); + + bool operator==( const JobSetup& rJobSetup ) const; + bool operator!=( const JobSetup& rJobSetup ) const + { return !(JobSetup::operator==( rJobSetup )); } + + SAL_DLLPRIVATE ImplJobSetup& ImplGetData(); + SAL_DLLPRIVATE const ImplJobSetup& ImplGetConstData() const; + + OUString const & GetPrinterName() const; + bool IsDefault() const; + + friend VCL_DLLPUBLIC SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup ); + friend VCL_DLLPUBLIC SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup ); + + typedef o3tl::cow_wrapper< ImplJobSetup > ImplType; + +private: + ImplType mpData; +}; + +#endif // INCLUDED_VCL_JOBSET_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/keycod.hxx b/include/vcl/keycod.hxx new file mode 100644 index 000000000..63bbf372f --- /dev/null +++ b/include/vcl/keycod.hxx @@ -0,0 +1,120 @@ +/* -*- 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_KEYCOD_HXX +#define INCLUDED_VCL_KEYCOD_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <vcl/keycodes.hxx> + +namespace vcl { class Window; } + +enum class KeyFuncType : sal_Int32 { DONTKNOW, NEW, OPEN, SAVE, + SAVEAS, PRINT, CLOSE, QUIT, + CUT, COPY, PASTE, UNDO, + REDO, DELETE, REPEAT, FIND, + FINDBACKWARD, PROPERTIES, FRONT }; + +namespace vcl +{ + +class VCL_DLLPUBLIC KeyCode +{ +private: + sal_uInt16 nKeyCodeAndModifiers; + KeyFuncType eFunc; + +public: + KeyCode() { nKeyCodeAndModifiers = 0; eFunc = KeyFuncType::DONTKNOW; } + KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier = 0 ); + KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 ); + KeyCode( KeyFuncType eFunction ); + + sal_uInt16 GetFullCode() const { return nKeyCodeAndModifiers; } + KeyFuncType GetFullFunction() const { return eFunc; } + + sal_uInt16 GetCode() const + { return (nKeyCodeAndModifiers & KEY_CODE_MASK); } + + sal_uInt16 GetModifier() const + { return (nKeyCodeAndModifiers & KEY_MODIFIERS_MASK); } + bool IsShift() const + { return ((nKeyCodeAndModifiers & KEY_SHIFT) != 0); } + bool IsMod1() const + { return ((nKeyCodeAndModifiers & KEY_MOD1) != 0); } + bool IsMod2() const + { return ((nKeyCodeAndModifiers & KEY_MOD2) != 0); } + bool IsMod3() const + { return ((nKeyCodeAndModifiers & KEY_MOD3) != 0); } + sal_uInt16 GetGroup() const + { return (nKeyCodeAndModifiers & KEYGROUP_TYPE); } + + OUString GetName( vcl::Window* pWindow = nullptr ) const; + + bool IsFunction() const + { return (eFunc != KeyFuncType::DONTKNOW); } + + KeyFuncType GetFunction() const; + + bool operator ==( const KeyCode& rKeyCode ) const; + bool operator !=( const KeyCode& rKeyCode ) const; +}; + +} // namespace vcl + +inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, sal_uInt16 nModifier ) +{ + nKeyCodeAndModifiers = nKey | nModifier; + eFunc = KeyFuncType::DONTKNOW; +} + +inline vcl::KeyCode::KeyCode( sal_uInt16 nKey, bool bShift, bool bMod1, bool bMod2, bool bMod3 ) +{ + nKeyCodeAndModifiers = nKey; + if( bShift ) + nKeyCodeAndModifiers |= KEY_SHIFT; + if( bMod1 ) + nKeyCodeAndModifiers |= KEY_MOD1; + if( bMod2 ) + nKeyCodeAndModifiers |= KEY_MOD2; + if( bMod3 ) + nKeyCodeAndModifiers |= KEY_MOD3; + eFunc = KeyFuncType::DONTKNOW; +} + +inline bool vcl::KeyCode::operator ==( const vcl::KeyCode& rKeyCode ) const +{ + if ( (eFunc == KeyFuncType::DONTKNOW) && (rKeyCode.eFunc == KeyFuncType::DONTKNOW) ) + return (nKeyCodeAndModifiers == rKeyCode.nKeyCodeAndModifiers); + else + return (GetFunction() == rKeyCode.GetFunction()); +} + +inline bool vcl::KeyCode::operator !=( const vcl::KeyCode& rKeyCode ) const +{ + if ( (eFunc == KeyFuncType::DONTKNOW) && (rKeyCode.eFunc == KeyFuncType::DONTKNOW) ) + return (nKeyCodeAndModifiers != rKeyCode.nKeyCodeAndModifiers); + else + return (GetFunction() != rKeyCode.GetFunction()); +} + +#endif // INCLUDED_VCL_KEYCOD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/keycodes.hxx b/include/vcl/keycodes.hxx new file mode 100644 index 000000000..c262610fd --- /dev/null +++ b/include/vcl/keycodes.hxx @@ -0,0 +1,193 @@ +/* -*- 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_KEYCODES_HXX +#define INCLUDED_VCL_KEYCODES_HXX + +#include <com/sun/star/awt/Key.hpp> +#include <com/sun/star/awt/KeyGroup.hpp> +#include <o3tl/typed_flags_set.hxx> + +constexpr sal_uInt16 KEY_CODE_MASK = 0x0FFF; + +// Modifier keys +constexpr sal_uInt16 KEY_SHIFT = 0x1000; +constexpr sal_uInt16 KEY_MOD1 = 0x2000; +constexpr sal_uInt16 KEY_MOD2 = 0x4000; +constexpr sal_uInt16 KEY_MOD3 = 0x8000; +constexpr sal_uInt16 KEY_MODIFIERS_MASK = 0xF000; + +// Key groups +constexpr sal_uInt16 KEYGROUP_NUM = css::awt::KeyGroup::NUM; +constexpr sal_uInt16 KEYGROUP_ALPHA = css::awt::KeyGroup::ALPHA; +constexpr sal_uInt16 KEYGROUP_FKEYS = css::awt::KeyGroup::FKEYS; +constexpr sal_uInt16 KEYGROUP_CURSOR = css::awt::KeyGroup::CURSOR; +constexpr sal_uInt16 KEYGROUP_MISC = css::awt::KeyGroup::MISC; +constexpr sal_uInt16 KEYGROUP_TYPE = css::awt::KeyGroup::TYPE; + +// Key codes +constexpr sal_uInt16 KEY_0 = css::awt::Key::NUM0; +constexpr sal_uInt16 KEY_1 = css::awt::Key::NUM1; +constexpr sal_uInt16 KEY_2 = css::awt::Key::NUM2; +constexpr sal_uInt16 KEY_3 = css::awt::Key::NUM3; +constexpr sal_uInt16 KEY_4 = css::awt::Key::NUM4; +constexpr sal_uInt16 KEY_5 = css::awt::Key::NUM5; +constexpr sal_uInt16 KEY_6 = css::awt::Key::NUM6; +constexpr sal_uInt16 KEY_7 = css::awt::Key::NUM7; +constexpr sal_uInt16 KEY_8 = css::awt::Key::NUM8; +constexpr sal_uInt16 KEY_9 = css::awt::Key::NUM9; + +constexpr sal_uInt16 KEY_A = css::awt::Key::A; +constexpr sal_uInt16 KEY_B = css::awt::Key::B; +constexpr sal_uInt16 KEY_C = css::awt::Key::C; +constexpr sal_uInt16 KEY_D = css::awt::Key::D; +constexpr sal_uInt16 KEY_E = css::awt::Key::E; +constexpr sal_uInt16 KEY_F = css::awt::Key::F; +constexpr sal_uInt16 KEY_G = css::awt::Key::G; +constexpr sal_uInt16 KEY_H = css::awt::Key::H; +constexpr sal_uInt16 KEY_I = css::awt::Key::I; +constexpr sal_uInt16 KEY_J = css::awt::Key::J; +constexpr sal_uInt16 KEY_K = css::awt::Key::K; +constexpr sal_uInt16 KEY_L = css::awt::Key::L; +constexpr sal_uInt16 KEY_M = css::awt::Key::M; +constexpr sal_uInt16 KEY_N = css::awt::Key::N; +constexpr sal_uInt16 KEY_O = css::awt::Key::O; +constexpr sal_uInt16 KEY_P = css::awt::Key::P; +constexpr sal_uInt16 KEY_Q = css::awt::Key::Q; +constexpr sal_uInt16 KEY_R = css::awt::Key::R; +constexpr sal_uInt16 KEY_S = css::awt::Key::S; +constexpr sal_uInt16 KEY_T = css::awt::Key::T; +constexpr sal_uInt16 KEY_U = css::awt::Key::U; +constexpr sal_uInt16 KEY_V = css::awt::Key::V; +constexpr sal_uInt16 KEY_W = css::awt::Key::W; +constexpr sal_uInt16 KEY_X = css::awt::Key::X; +constexpr sal_uInt16 KEY_Y = css::awt::Key::Y; +constexpr sal_uInt16 KEY_Z = css::awt::Key::Z; + +constexpr sal_uInt16 KEY_F1 = css::awt::Key::F1; +constexpr sal_uInt16 KEY_F2 = css::awt::Key::F2; +constexpr sal_uInt16 KEY_F3 = css::awt::Key::F3; +constexpr sal_uInt16 KEY_F4 = css::awt::Key::F4; +constexpr sal_uInt16 KEY_F5 = css::awt::Key::F5; +constexpr sal_uInt16 KEY_F6 = css::awt::Key::F6; +constexpr sal_uInt16 KEY_F7 = css::awt::Key::F7; +constexpr sal_uInt16 KEY_F8 = css::awt::Key::F8; +constexpr sal_uInt16 KEY_F9 = css::awt::Key::F9; +constexpr sal_uInt16 KEY_F10 = css::awt::Key::F10; +constexpr sal_uInt16 KEY_F11 = css::awt::Key::F11; +constexpr sal_uInt16 KEY_F12 = css::awt::Key::F12; +constexpr sal_uInt16 KEY_F13 = css::awt::Key::F13; +constexpr sal_uInt16 KEY_F14 = css::awt::Key::F14; +constexpr sal_uInt16 KEY_F15 = css::awt::Key::F15; +constexpr sal_uInt16 KEY_F16 = css::awt::Key::F16; +constexpr sal_uInt16 KEY_F17 = css::awt::Key::F17; +constexpr sal_uInt16 KEY_F18 = css::awt::Key::F18; +constexpr sal_uInt16 KEY_F19 = css::awt::Key::F19; +constexpr sal_uInt16 KEY_F20 = css::awt::Key::F20; +constexpr sal_uInt16 KEY_F21 = css::awt::Key::F21; +constexpr sal_uInt16 KEY_F22 = css::awt::Key::F22; +constexpr sal_uInt16 KEY_F23 = css::awt::Key::F23; +constexpr sal_uInt16 KEY_F24 = css::awt::Key::F24; +constexpr sal_uInt16 KEY_F25 = css::awt::Key::F25; +constexpr sal_uInt16 KEY_F26 = css::awt::Key::F26; + +constexpr sal_uInt16 KEY_DOWN = css::awt::Key::DOWN; +constexpr sal_uInt16 KEY_UP = css::awt::Key::UP; +constexpr sal_uInt16 KEY_LEFT = css::awt::Key::LEFT; +constexpr sal_uInt16 KEY_RIGHT = css::awt::Key::RIGHT; +constexpr sal_uInt16 KEY_HOME = css::awt::Key::HOME; +constexpr sal_uInt16 KEY_END = css::awt::Key::END; +constexpr sal_uInt16 KEY_PAGEUP = css::awt::Key::PAGEUP; +constexpr sal_uInt16 KEY_PAGEDOWN = css::awt::Key::PAGEDOWN; + +constexpr sal_uInt16 KEY_RETURN = css::awt::Key::RETURN; +constexpr sal_uInt16 KEY_ESCAPE = css::awt::Key::ESCAPE; +constexpr sal_uInt16 KEY_TAB = css::awt::Key::TAB; +constexpr sal_uInt16 KEY_BACKSPACE = css::awt::Key::BACKSPACE; +constexpr sal_uInt16 KEY_SPACE = css::awt::Key::SPACE; +constexpr sal_uInt16 KEY_INSERT = css::awt::Key::INSERT; +constexpr sal_uInt16 KEY_DELETE = css::awt::Key::DELETE; + +constexpr sal_uInt16 KEY_ADD = css::awt::Key::ADD; +constexpr sal_uInt16 KEY_SUBTRACT = css::awt::Key::SUBTRACT; +constexpr sal_uInt16 KEY_MULTIPLY = css::awt::Key::MULTIPLY; +constexpr sal_uInt16 KEY_DIVIDE = css::awt::Key::DIVIDE; +constexpr sal_uInt16 KEY_POINT = css::awt::Key::POINT; +constexpr sal_uInt16 KEY_COMMA = css::awt::Key::COMMA; +constexpr sal_uInt16 KEY_LESS = css::awt::Key::LESS; +constexpr sal_uInt16 KEY_GREATER = css::awt::Key::GREATER; +constexpr sal_uInt16 KEY_EQUAL = css::awt::Key::EQUAL; + +constexpr sal_uInt16 KEY_OPEN = css::awt::Key::OPEN; +constexpr sal_uInt16 KEY_CUT = css::awt::Key::CUT; +constexpr sal_uInt16 KEY_COPY = css::awt::Key::COPY; +constexpr sal_uInt16 KEY_PASTE = css::awt::Key::PASTE; +constexpr sal_uInt16 KEY_UNDO = css::awt::Key::UNDO; +constexpr sal_uInt16 KEY_REPEAT = css::awt::Key::REPEAT; +constexpr sal_uInt16 KEY_FIND = css::awt::Key::FIND; +constexpr sal_uInt16 KEY_PROPERTIES = css::awt::Key::PROPERTIES; +constexpr sal_uInt16 KEY_FRONT = css::awt::Key::FRONT; +constexpr sal_uInt16 KEY_CONTEXTMENU = css::awt::Key::CONTEXTMENU; +constexpr sal_uInt16 KEY_MENU = css::awt::Key::MENU; +constexpr sal_uInt16 KEY_HELP = css::awt::Key::HELP; +constexpr sal_uInt16 KEY_HANGUL_HANJA = css::awt::Key::HANGUL_HANJA; +constexpr sal_uInt16 KEY_DECIMAL = css::awt::Key::DECIMAL; +constexpr sal_uInt16 KEY_TILDE = css::awt::Key::TILDE; +constexpr sal_uInt16 KEY_QUOTELEFT = css::awt::Key::QUOTELEFT; +constexpr sal_uInt16 KEY_BRACKETLEFT = css::awt::Key::BRACKETLEFT; +constexpr sal_uInt16 KEY_BRACKETRIGHT = css::awt::Key::BRACKETRIGHT; +constexpr sal_uInt16 KEY_SEMICOLON = css::awt::Key::SEMICOLON; +constexpr sal_uInt16 KEY_QUOTERIGHT = css::awt::Key::QUOTERIGHT; + +constexpr sal_uInt16 KEY_CAPSLOCK = css::awt::Key::CAPSLOCK; +constexpr sal_uInt16 KEY_NUMLOCK = css::awt::Key::NUMLOCK; +constexpr sal_uInt16 KEY_SCROLLLOCK = css::awt::Key::SCROLLLOCK; + +// extended Modifier-Keys (only used for modkey events) +enum class ModKeyFlags { + NONE = 0x0000, + LeftShift = 0x0001, + RightShift = 0x0002, + LeftMod1 = 0x0004, + RightMod1 = 0x0008, + LeftMod2 = 0x0010, + RightMod2 = 0x0020, + LeftMod3 = 0x0040, + RightMod3 = 0x0080, + Mod1Msk = LeftMod1 | RightMod1, // should be Mod1Mask, but that conflicts with a X.h macro grrrr + Mod2Msk = LeftMod2 | RightMod2, +}; +namespace o3tl { + template<> struct typed_flags<ModKeyFlags> : is_typed_flags<ModKeyFlags, 0x00ff> {}; +} + +enum class KeyIndicatorState { + NONE = 0x0000, + CAPSLOCK = 0x0001, + NUMLOCK = 0x0002, + SCROLLLOCK = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags<KeyIndicatorState> : is_typed_flags<KeyIndicatorState, 0x0007> {}; +} + +#endif // INCLUDED_VCL_KEYCODES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx new file mode 100644 index 000000000..179a03421 --- /dev/null +++ b/include/vcl/layout.hxx @@ -0,0 +1,865 @@ +/* -*- 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_LAYOUT_HXX +#define INCLUDED_VCL_LAYOUT_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/help.hxx> +#include <vcl/svapp.hxx> +#include <vcl/window.hxx> +#include <vcl/settings.hxx> +#include <vcl/event.hxx> +#include <vcl/transfer.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/IContext.hxx> +#include <vcl/commandevent.hxx> +#include <set> + +class ScrollBar; +class ScrollBar; +class ScrollBarBox; +class Splitter; + +class VCL_DLLPUBLIC VclContainer : public vcl::Window, + public vcl::IContext +{ +public: + VclContainer(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN); + + //These take into account the external margins of the rWindow widget + //while GetOptimalSize/get_preferred_size and SetPosSizePixel are + //oblivious to them + static Size getLayoutRequisition(const vcl::Window &rWindow); + static void setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize); + + //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account + //the rWindows alignment desires within that allocation + static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize); + + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; +protected: + //these are the two that need to be implemented by + //containers, figure out how much space you want... + virtual Size calculateRequisition() const = 0; + //..and decide what to do when set to this size + virtual void setAllocation(const Size &rAllocation) = 0; + + virtual sal_uInt16 getDefaultAccessibleRole() const override; + + // support for screenshot context menu + virtual void Command(const CommandEvent& rCEvt) override; + +public: + //you don't want to override these + virtual Size GetOptimalSize() const override; + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override; + virtual void SetPosPixel(const Point& rAllocPos) override; + virtual void SetSizePixel(const Size& rAllocation) override; +private: + bool m_bLayoutDirty; +}; + +class VCL_DLLPUBLIC VclBox : public VclContainer +{ +protected: + bool m_bHomogeneous; + bool m_bVerticalContainer; + int m_nSpacing; +public: + VclBox(vcl::Window *pParent, bool bHomogeneous, int nSpacing) + : VclContainer(pParent) + , m_bHomogeneous(bHomogeneous) + , m_bVerticalContainer(false) + , m_nSpacing(nSpacing) + { + } + void set_spacing(int nSpacing) + { + m_nSpacing = nSpacing; + } + int get_spacing() const + { + return m_nSpacing; + } + void set_homogeneous(bool bHomogeneous) + { + m_bHomogeneous = bHomogeneous; + } + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +protected: + virtual sal_uInt16 getDefaultAccessibleRole() const override; + void accumulateMaxes(const Size &rChildSize, Size &rSize) const; + Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const; + + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + + virtual long getPrimaryDimension(const Size &rSize) const = 0; + virtual void setPrimaryDimension(Size &rSize, long) const = 0; + virtual long getPrimaryCoordinate(const Point &rPos) const = 0; + virtual void setPrimaryCoordinate(Point &rPos, long) const = 0; + virtual long getSecondaryDimension(const Size &rSize) const = 0; + virtual void setSecondaryDimension(Size &rSize, long) const = 0; + + virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0; +}; + +class VCL_DLLPUBLIC VclVBox : public VclBox +{ +public: + VclVBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) + { + m_bVerticalContainer = true; + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const override + { + return rSize.getHeight(); + } + virtual void setPrimaryDimension(Size &rSize, long nHeight) const override + { + rSize.setHeight(nHeight); + } + virtual long getPrimaryCoordinate(const Point &rPos) const override + { + return rPos.getY(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override + { + rPos.setY(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const override + { + return rSize.getWidth(); + } + virtual void setSecondaryDimension(Size &rSize, long nWidth) const override + { + rSize.setWidth(nWidth); + } + virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override + { + return rWindow.get_expand() || rWindow.get_vexpand(); + } +}; + +class VCL_DLLPUBLIC VclHBox : public VclBox +{ +public: + VclHBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0) + : VclBox(pParent, bHomogeneous, nSpacing) + { + m_bVerticalContainer = false; + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const override + { + return rSize.getWidth(); + } + virtual void setPrimaryDimension(Size &rSize, long nWidth) const override + { + rSize.setWidth(nWidth); + } + virtual long getPrimaryCoordinate(const Point &rPos) const override + { + return rPos.getX(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override + { + rPos.setX(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const override + { + return rSize.getHeight(); + } + virtual void setSecondaryDimension(Size &rSize, long nHeight) const override + { + rSize.setHeight(nHeight); + } + virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override + { + return rWindow.get_expand() || rWindow.get_hexpand(); + } +}; + +enum class VclButtonBoxStyle +{ + Default, + Spread, + Edge, + Start, + End, + Center +}; + +class VCL_DLLPUBLIC VclButtonBox : public VclBox +{ +public: + VclButtonBox(vcl::Window *pParent) + : VclBox(pParent, false, Application::GetSettings().GetStyleSettings().GetDialogStyle().button_spacing) + , m_eLayoutStyle(VclButtonBoxStyle::Default) + { + } + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + void sort_native_button_order(); +protected: + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const; +private: + VclButtonBoxStyle m_eLayoutStyle; + struct Requisition + { + std::vector<long> m_aMainGroupDimensions; + std::vector<long> m_aSubGroupDimensions; + Size m_aMainGroupSize; + Size m_aSubGroupSize; + }; + Requisition calculatePrimarySecondaryRequisitions() const; + Size addReqGroups(const VclButtonBox::Requisition &rReq) const; +}; + +class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox +{ +public: + VclVButtonBox(vcl::Window *pParent) + : VclButtonBox(pParent) + { + m_bVerticalContainer = true; + } +protected: + virtual long getPrimaryDimension(const Size &rSize) const override + { + return rSize.getHeight(); + } + virtual void setPrimaryDimension(Size &rSize, long nHeight) const override + { + rSize.setHeight(nHeight); + } + virtual long getPrimaryCoordinate(const Point &rPos) const override + { + return rPos.getY(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override + { + rPos.setY(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const override + { + return rSize.getWidth(); + } + virtual void setSecondaryDimension(Size &rSize, long nWidth) const override + { + rSize.setWidth(nWidth); + } + virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override + { + return rWindow.get_expand() || rWindow.get_vexpand(); + } +}; + +class VCL_DLLPUBLIC VclHButtonBox final : public VclButtonBox +{ +public: + VclHButtonBox(vcl::Window *pParent) + : VclButtonBox(pParent) + { + m_bVerticalContainer = false; + } +private: + virtual long getPrimaryDimension(const Size &rSize) const override + { + return rSize.getWidth(); + } + virtual void setPrimaryDimension(Size &rSize, long nWidth) const override + { + rSize.setWidth(nWidth); + } + virtual long getPrimaryCoordinate(const Point &rPos) const override + { + return rPos.getX(); + } + virtual void setPrimaryCoordinate(Point &rPos, long nPos) const override + { + rPos.setX(nPos); + } + virtual long getSecondaryDimension(const Size &rSize) const override + { + return rSize.getHeight(); + } + virtual void setSecondaryDimension(Size &rSize, long nHeight) const override + { + rSize.setHeight(nHeight); + } + virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const override + { + return rWindow.get_expand() || rWindow.get_hexpand(); + } +}; + +class VCL_DLLPUBLIC VclGrid final : public VclContainer +{ +private: + bool m_bRowHomogeneous; + bool m_bColumnHomogeneous; + int m_nRowSpacing; + int m_nColumnSpacing; + +public: + struct Value + { + long m_nValue; + bool m_bExpand; + Value() : m_nValue(0), m_bExpand(false) {} + }; +private: + + Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +public: + VclGrid(vcl::Window *pParent) + : VclContainer(pParent) + , m_bRowHomogeneous(false), m_bColumnHomogeneous(false) + , m_nRowSpacing(0), m_nColumnSpacing(0) + { + } + bool get_row_homogeneous() const + { + return m_bRowHomogeneous; + } + bool get_column_homogeneous() const + { + return m_bColumnHomogeneous; + } + void set_row_spacing(int nSpacing) + { + m_nRowSpacing = nSpacing; + } + void set_column_spacing(int nSpacing) + { + m_nColumnSpacing = nSpacing; + } + int get_row_spacing() const + { + return m_nRowSpacing; + } + int get_column_spacing() const + { + return m_nColumnSpacing; + } + virtual bool set_property(const OString &rKey, const OUString &rValue) override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) VclBin : public VclContainer +{ +public: + VclBin(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN) + : VclContainer(pParent, nStyle) + { + } + virtual vcl::Window *get_child(); + virtual const vcl::Window *get_child() const; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; +}; + +class VclPaned : public VclContainer +{ +protected: + VclPtr<Splitter> m_pSplitter; + long m_nPosition; + + VclPaned(vcl::Window *pParent, bool bVertical); +public: + virtual ~VclPaned() override; + virtual void dispose() override; + long get_position() const { return m_nPosition; } + virtual void set_position(long nPosition) { m_nPosition = nPosition; } +}; + +class VclVPaned final : public VclPaned +{ +private: + DECL_LINK(SplitHdl, Splitter*, void); + void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight); + +public: + VclVPaned(vcl::Window *pParent); + virtual ~VclVPaned() override; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + virtual void set_position(long nPosition) override; +}; + +class VclHPaned final : public VclPaned +{ +private: + DECL_LINK(SplitHdl, Splitter*, void); + void arrange(const Size& rAllocation, long nFirstHeight, long nSecondHeight); + +public: + VclHPaned(vcl::Window *pParent); + virtual ~VclHPaned() override; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + virtual void set_position(long nPosition) override; +}; + +class VclFrame final : public VclBin +{ +private: + VclPtr<vcl::Window> m_pLabel; +private: + friend class VclBuilder; + void designate_label(vcl::Window *pWindow); + DECL_LINK(WindowEventListener, VclWindowEvent&, void); +public: + VclFrame(vcl::Window *pParent) + : VclBin(pParent) + , m_pLabel(nullptr) + { + } + virtual ~VclFrame() override; + virtual void dispose() override; + void set_label(const OUString &rLabel); + OUString get_label() const; + virtual vcl::Window *get_child() override; + virtual const vcl::Window *get_child() const override; + vcl::Window *get_label_widget(); + const vcl::Window *get_label_widget() const; + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +private: + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + virtual OUString getDefaultAccessibleName() const override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) VclAlignment final : public VclBin +{ +public: + VclAlignment(vcl::Window *pParent) + : VclBin(pParent) + , m_nBottomPadding(0) + , m_nLeftPadding(0) + , m_nRightPadding(0) + , m_nTopPadding(0) + { + } + virtual bool set_property(const OString &rKey, const OUString &rValue) override; +private: + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + sal_Int32 m_nBottomPadding; + sal_Int32 m_nLeftPadding; + sal_Int32 m_nRightPadding; + sal_Int32 m_nTopPadding; +}; + +class DisclosureButton; +class CheckBox; + +class VclExpander final : public VclBin +{ +public: + VclExpander(vcl::Window *pParent); + virtual ~VclExpander() override; + virtual void dispose() override; + virtual vcl::Window *get_child() override; + virtual const vcl::Window *get_child() const override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + bool get_expanded() const; + void set_expanded(bool bExpanded); + void set_label(const OUString& rLabel); + virtual void StateChanged(StateChangedType nType) override; + void SetExpandedHdl( const Link<VclExpander&,void>& rLink ) { maExpandedHdl = rLink; } +private: + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + bool m_bResizeTopLevel; + VclPtr<DisclosureButton> m_pDisclosureButton; + Link<VclExpander&,void> maExpandedHdl; + DECL_LINK(ClickHdl, CheckBox&, void); +}; + +class VCL_DLLPUBLIC VclScrolledWindow final : public VclBin +{ +public: + VclScrolledWindow(vcl::Window *pParent ); + virtual ~VclScrolledWindow() override; + virtual void dispose() override; + virtual vcl::Window *get_child() override; + virtual const vcl::Window *get_child() const override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + ScrollBar& getVertScrollBar() { return *m_pVScroll; } + ScrollBar& getHorzScrollBar() { return *m_pHScroll; } + Size getVisibleChildSize() const; + //set to true to disable the built-in scrolling callbacks to allow the user + //to override it + void setUserManagedScrolling(bool bUserManagedScrolling) { m_bUserManagedScrolling = bUserManagedScrolling;} + void doSetAllocation(const Size &rAllocation, bool bRetryOnFailure); +private: + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + DECL_LINK(ScrollBarHdl, ScrollBar*, void); + void InitScrollBars(const Size &rRequest); + virtual bool EventNotify(NotifyEvent& rNEvt) override; + bool m_bUserManagedScrolling; + DrawFrameStyle m_eDrawFrameStyle; + VclPtr<ScrollBar> m_pVScroll; + VclPtr<ScrollBar> m_pHScroll; + VclPtr<ScrollBarBox> m_aScrollBarBox; +}; + +class VclViewport final : public VclBin +{ +public: + VclViewport(vcl::Window *pParent) + : VclBin(pParent, WB_HIDE | WB_CLIPCHILDREN) + , m_bInitialAllocation(true) + { + } +private: + virtual void setAllocation(const Size &rAllocation) override; + bool m_bInitialAllocation; +}; + +//Enforces that its children are always the same size as itself. +//Intercepts any Commands intended for its children. +// +//by default the Commands are discarded, inherit from this +//and implement "Command" to get them +class VclEventBox final : public VclBin +{ +private: + //Any Commands an EventBoxHelper receives are forwarded to its parent + //The VclEventBox ensures that m_aEventBoxHelper is the + //first child and is transparent, but covers the rest of the children + class EventBoxHelper : public vcl::Window + { + public: + EventBoxHelper(vcl::Window* pParent) + : Window(pParent, 0) + { + SetSizePixel(pParent->GetSizePixel()); + EnableChildTransparentMode(); + SetPaintTransparent(true); + SetBackground(); + } + virtual void Command(const CommandEvent& rCEvt) override + { + GetParent()->Command(rCEvt); + } + }; + + VclPtr<EventBoxHelper> m_aEventBoxHelper; + virtual void dispose() override; + virtual ~VclEventBox() override; +public: + VclEventBox(vcl::Window* pParent) + : VclBin(pParent) + , m_aEventBoxHelper(VclPtr<EventBoxHelper>::Create(this)) + { + m_aEventBoxHelper->Show(); + } + virtual vcl::Window *get_child() override; + virtual const vcl::Window *get_child() const override; + virtual Size calculateRequisition() const override; + virtual void setAllocation(const Size &rAllocation) override; + + virtual void Command(const CommandEvent& rCEvt) override; +}; + +class VclSizeGroup +{ +private: + std::set< VclPtr<vcl::Window> > m_aWindows; + bool m_bIgnoreHidden; + VclSizeGroupMode m_eMode; + + void trigger_queue_resize(); +public: + VclSizeGroup() + : m_bIgnoreHidden(false) + , m_eMode(VclSizeGroupMode::Horizontal) + { + } + void insert(vcl::Window *pWindow) + { + m_aWindows.insert(VclPtr<vcl::Window>(pWindow)); + } + void erase(vcl::Window *pWindow) + { + m_aWindows.erase(VclPtr<vcl::Window>(pWindow)); + } + const std::set< VclPtr<vcl::Window> >& get_widgets() const + { + return m_aWindows; + } + std::set< VclPtr<vcl::Window> >& get_widgets() + { + return m_aWindows; + } + void set_ignore_hidden(bool bIgnoreHidden); + bool get_ignore_hidden() const + { + return m_bIgnoreHidden; + } + void set_mode(VclSizeGroupMode eMode); + VclSizeGroupMode get_mode() const + { + return m_eMode; + } + void set_property(const OString &rKey, const OUString &rValue); +}; + +class VCL_DLLPUBLIC VclDrawingArea final : public Control + , public DragSourceHelper +{ +private: + FactoryFunction m_pFactoryFunction; + void* m_pUserData; + rtl::Reference<TransferDataContainer> m_xTransferHelper; + sal_Int8 m_nDragAction; + Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void> m_aPaintHdl; + Link<const Size&, void> m_aResizeHdl; + Link<const MouseEvent&, bool> m_aMousePressHdl; + Link<const MouseEvent&, bool> m_aMouseMotionHdl; + Link<const MouseEvent&, bool> m_aMouseReleaseHdl; + Link<const KeyEvent&, bool> m_aKeyPressHdl; + Link<const KeyEvent&, bool> m_aKeyReleaseHdl; + Link<VclDrawingArea&, void> m_aStyleUpdatedHdl; + Link<const CommandEvent&, bool> m_aCommandHdl; + Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl; + Link<OUString&, int> m_aGetSurroundingHdl; + Link<VclDrawingArea*, bool> m_aStartDragHdl; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override + { + m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect)); + } + virtual void Resize() override + { + m_aResizeHdl.Call(GetOutputSizePixel()); + } + virtual void MouseMove(const MouseEvent& rMEvt) override + { + if (!m_aMouseMotionHdl.Call(rMEvt)) + Control::MouseMove(rMEvt); + } + virtual void MouseButtonDown(const MouseEvent& rMEvt) override + { + if (!m_aMousePressHdl.Call(rMEvt)) + Control::MouseButtonDown(rMEvt); + } + virtual void MouseButtonUp(const MouseEvent& rMEvt) override + { + if (!m_aMouseReleaseHdl.Call(rMEvt)) + Control::MouseButtonUp(rMEvt); + } + virtual void KeyInput(const KeyEvent& rKEvt) override + { + if (!m_aKeyPressHdl.Call(rKEvt)) + Control::KeyInput(rKEvt); + + } + virtual void KeyUp(const KeyEvent& rKEvt) override + { + if (!m_aKeyReleaseHdl.Call(rKEvt)) + Control::KeyUp(rKEvt); + } + virtual void StateChanged(StateChangedType nType) override + { + Control::StateChanged(nType); + if (nType == StateChangedType::ControlForeground || nType == StateChangedType::ControlBackground) + { + m_aStyleUpdatedHdl.Call(*this); + Invalidate(); + } + } + virtual void DataChanged(const DataChangedEvent& rDCEvt) override + { + Control::DataChanged(rDCEvt); + if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) + { + m_aStyleUpdatedHdl.Call(*this); + Invalidate(); + } + } + virtual void Command(const CommandEvent& rEvent) override + { + if (m_aCommandHdl.Call(rEvent)) + return; + Control::Command(rEvent); + } + virtual void RequestHelp(const HelpEvent& rHelpEvent) override + { + if (rHelpEvent.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON)) + { + Point aPos(ScreenToOutputPixel(rHelpEvent.GetMousePosPixel())); + tools::Rectangle aHelpArea(aPos.X(), aPos.Y()); + OUString sHelpTip = m_aQueryTooltipHdl.Call(aHelpArea); + if (sHelpTip.isEmpty()) + return; + Point aPt = OutputToScreenPixel(aHelpArea.TopLeft()); + aHelpArea.SetLeft(aPt.X()); + aHelpArea.SetTop(aPt.Y()); + aPt = OutputToScreenPixel(aHelpArea.BottomRight()); + aHelpArea.SetRight(aPt.X()); + aHelpArea.SetBottom(aPt.Y()); + // tdf#125369 recover newline support of tdf#101779 + QuickHelpFlags eHelpWinStyle = sHelpTip.indexOf('\n') != -1 ? QuickHelpFlags::TipStyleBalloon : QuickHelpFlags::NONE; + Help::ShowQuickHelp(this, aHelpArea, sHelpTip, eHelpWinStyle); + } + } + virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override; + virtual FactoryFunction GetUITestFactory() const override + { + if (m_pFactoryFunction) + return m_pFactoryFunction; + return Control::GetUITestFactory(); + } + +public: + VclDrawingArea(vcl::Window *pParent, WinBits nStyle) + : Control(pParent, nStyle) + , DragSourceHelper(this) + , m_pFactoryFunction(nullptr) + , m_pUserData(nullptr) + , m_nDragAction(0) + { + SetBackground(); + } + virtual OUString GetSurroundingText() const override; + virtual Selection GetSurroundingTextSelection() const override; + void SetUITestFactory(FactoryFunction pFactoryFunction, void* pUserData) + { + m_pFactoryFunction = pFactoryFunction; + m_pUserData = pUserData; + } + void* GetUserData() const + { + return m_pUserData; + } + void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink) + { + m_aPaintHdl = rLink; + } + void SetResizeHdl(const Link<const Size&, void>& rLink) + { + m_aResizeHdl = rLink; + } + void SetMousePressHdl(const Link<const MouseEvent&, bool>& rLink) + { + m_aMousePressHdl = rLink; + } + void SetMouseMoveHdl(const Link<const MouseEvent&, bool>& rLink) + { + m_aMouseMotionHdl = rLink; + } + void SetMouseReleaseHdl(const Link<const MouseEvent&, bool>& rLink) + { + m_aMouseReleaseHdl = rLink; + } + void SetKeyPressHdl(const Link<const KeyEvent&, bool>& rLink) + { + m_aKeyPressHdl = rLink; + } + void SetKeyReleaseHdl(const Link<const KeyEvent&, bool>& rLink) + { + m_aKeyReleaseHdl = rLink; + } + void SetStyleUpdatedHdl(const Link<VclDrawingArea&, void>& rLink) + { + m_aStyleUpdatedHdl = rLink; + } + void SetCommandHdl(const Link<const CommandEvent&, bool>& rLink) + { + m_aCommandHdl = rLink; + } + void SetQueryTooltipHdl(const Link<tools::Rectangle&, OUString>& rLink) + { + m_aQueryTooltipHdl = rLink; + } + void SetGetSurroundingHdl(const Link<OUString&, int>& rLink) + { + m_aGetSurroundingHdl = rLink; + } + void SetStartDragHdl(const Link<VclDrawingArea*, bool>& rLink) + { + m_aStartDragHdl = rLink; + } + void SetDragHelper(rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants) + { + m_xTransferHelper = rHelper; + m_nDragAction = eDNDConstants; + } +}; + +//Get first window of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(GetWindowType::FirstChild); +//in a flat hierarchy where dialogs only have one layer +//of children +vcl::Window* firstLogicalChildOfParent(const vcl::Window *pTopLevel); + +//Get last window of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(GetWindowType::LastChild); +//in a flat hierarchy where dialogs only have one layer +//of children +vcl::Window* lastLogicalChildOfParent(const vcl::Window *pTopLevel); + +//Get next window after pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(GetWindowType::Next); +//in a flat hierarchy where dialogs only have one layer +//of children +vcl::Window* nextLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild); + +//Get previous window before pChild of a pTopLevel window as +//if any intermediate layout widgets didn't exist +//i.e. acts like pChild = pChild->GetWindow(GetWindowType::Prev); +//in a flat hierarchy where dialogs only have one layer +//of children +vcl::Window* prevLogicalChildOfParent(const vcl::Window *pTopLevel, const vcl::Window *pChild); + +//Returns true is the Window has a single child which is a container +VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow); + +inline bool isContainerWindow(const vcl::Window &rWindow) +{ + WindowType eType = rWindow.GetType(); + return eType == WindowType::CONTAINER || eType == WindowType::SCROLLWINDOW || + (eType == WindowType::DOCKINGWINDOW && ::isLayoutEnabled(&rWindow)); +} + +inline bool isContainerWindow(const vcl::Window *pWindow) +{ + return pWindow && isContainerWindow(*pWindow); +} + +// retro-fitting utilities + +//Get a Size which is large enough to contain all children with +//an equal amount of space at top left and bottom right +Size getLegacyBestSizeForChildren(const vcl::Window &rWindow); + +//Get first parent which is not a layout widget +vcl::Window* getNonLayoutParent(vcl::Window *pParent); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lazydelete.hxx b/include/vcl/lazydelete.hxx new file mode 100644 index 000000000..1e253e54e --- /dev/null +++ b/include/vcl/lazydelete.hxx @@ -0,0 +1,121 @@ +/* -*- 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_LAZYDELETE_HXX +#define INCLUDED_VCL_LAZYDELETE_HXX + +#include <vcl/dllapi.h> + +#include <com/sun/star/lang/XComponent.hpp> + +#include <memory> + +namespace vcl +{ + /* + You may not access vcl objects after DeInitVCL has been called this includes their destruction + therefore disallowing the existence of static vcl object like e.g. a static BitmapEx + To work around this use DeleteOnDeinit<BitmapEx> which will allow you to have a static object container, + that will have its contents destroyed on DeinitVCL. The single drawback is that you need to check on the + container object whether it still contains content before actually accessing it. + + caveat: when constructing a vcl object, you certainly want to ensure that InitVCL has run already. + However this is not necessarily the case when using a class static member or a file level static variable. + In these cases make judicious use of the set() method of DeleteOnDeinit, but beware of the changing + ownership. + + example use case: use a lazy initialized on call BitmapEx in a paint method. Of course a paint method + would not normally be called after DeInitVCL anyway, so the check might not be necessary in a + Window::Paint implementation, but always checking is a good idea. + + SomeWindow::Paint() + { + static vcl::DeleteOnDeinit< BitmapEx > aBmp( new BitmapEx( ... ) ); + + if( aBmp.get() ) // check whether DeInitVCL has been called already + DrawBitmapEx( Point( 10, 10 ), *aBmp ); + } + */ + + class VCL_DLLPUBLIC DeleteOnDeinitBase + { + public: + static void SAL_DLLPRIVATE ImplDeleteOnDeInit(); + virtual ~DeleteOnDeinitBase(); + protected: + static void addDeinitContainer( DeleteOnDeinitBase* i_pContainer ); + + virtual void doCleanup() = 0; + }; + + template < typename T > + class DeleteOnDeinit final : public DeleteOnDeinitBase + { + std::unique_ptr<T> m_pT; + virtual void doCleanup() override { m_pT.reset(); } + public: + DeleteOnDeinit( T* i_pT ) : m_pT( i_pT ) { addDeinitContainer( this ); } + + // get contents + T* get() { return m_pT.get(); } + + // set contents, returning old contents + // ownership is transferred ! + std::unique_ptr<T> set( std::unique_ptr<T> i_pNew ) { auto pOld = std::move(m_pT); m_pT = std::move(i_pNew); return pOld; } + }; + + /** Similar to DeleteOnDeinit, the DeleteUnoReferenceOnDeinit + template class makes sure that a static UNO object is disposed + and released at the right time. + + Use like + static DeleteUnoReferenceOnDeinit<lang::XMultiServiceFactory> + xStaticFactory (\<create factory object>); + Reference<lang::XMultiServiceFactory> xFactory (xStaticFactory.get()); + if (xFactory.is()) + \<do something with xFactory> + */ + template <typename I> + class DeleteUnoReferenceOnDeinit final : public vcl::DeleteOnDeinitBase + { + css::uno::Reference<I> m_xI; + virtual void doCleanup() override { set(nullptr); } + public: + DeleteUnoReferenceOnDeinit(const css::uno::Reference<I>& r_xI ) : m_xI( r_xI ) { + addDeinitContainer( this ); } + + css::uno::Reference<I> get() { return m_xI; } + + void set (const css::uno::Reference<I>& r_xNew ) + { + css::uno::Reference< css::lang::XComponent> xComponent (m_xI, css::uno::UNO_QUERY); + m_xI = r_xNew; + if (xComponent.is()) try + { + xComponent->dispose(); + } + catch( css::uno::Exception& ) + { + } + } + }; +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lineinfo.hxx b/include/vcl/lineinfo.hxx new file mode 100644 index 000000000..09cc07407 --- /dev/null +++ b/include/vcl/lineinfo.hxx @@ -0,0 +1,114 @@ +/* -*- 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_LINEINFO_HXX +#define INCLUDED_VCL_LINEINFO_HXX + +#include <sal/types.h> +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <com/sun/star/drawing/LineCap.hpp> +#include <o3tl/cow_wrapper.hxx> + +class SvStream; +namespace basegfx { class B2DPolyPolygon; } + +struct ImplLineInfo +{ + sal_Int32 mnWidth; + sal_Int32 mnDashLen; + sal_Int32 mnDotLen; + sal_Int32 mnDistance; + + basegfx::B2DLineJoin meLineJoin; + css::drawing::LineCap meLineCap; + LineStyle meStyle; + + sal_uInt16 mnDashCount; + sal_uInt16 mnDotCount; + + ImplLineInfo(); + + bool operator==( const ImplLineInfo& ) const; +}; + + +class VCL_DLLPUBLIC LineInfo +{ +public: + LineInfo( LineStyle eLineStyle = LineStyle::Solid, sal_Int32 nWidth = 0 ); + LineInfo( const LineInfo& rLineInfo ); + LineInfo( LineInfo&& rLineInfo ); + ~LineInfo(); + + LineInfo& operator=( const LineInfo& rLineInfo ); + LineInfo& operator=( LineInfo&& rLineInfo ); + bool operator==( const LineInfo& rLineInfo ) const; + bool operator!=( const LineInfo& rLineInfo ) const { return !(LineInfo::operator==( rLineInfo ) ); } + + void SetStyle( LineStyle eStyle ); + LineStyle GetStyle() const { return mpImplLineInfo->meStyle; } + + void SetWidth( sal_Int32 nWidth ); + sal_Int32 GetWidth() const { return mpImplLineInfo->mnWidth; } + + void SetDashCount( sal_uInt16 nDashCount ); + sal_uInt16 GetDashCount() const { return mpImplLineInfo->mnDashCount; } + + void SetDashLen( sal_Int32 nDashLen ); + sal_Int32 GetDashLen() const { return mpImplLineInfo->mnDashLen; } + + void SetDotCount( sal_uInt16 nDotCount ); + sal_uInt16 GetDotCount() const { return mpImplLineInfo->mnDotCount; } + + void SetDotLen( sal_Int32 nDotLen ); + sal_Int32 GetDotLen() const { return mpImplLineInfo->mnDotLen; } + + void SetDistance( sal_Int32 nDistance ); + sal_Int32 GetDistance() const { return mpImplLineInfo->mnDistance; } + + void SetLineJoin(basegfx::B2DLineJoin eLineJoin); + basegfx::B2DLineJoin GetLineJoin() const { return mpImplLineInfo->meLineJoin; } + + void SetLineCap(css::drawing::LineCap eLineCap); + css::drawing::LineCap GetLineCap() const { return mpImplLineInfo->meLineCap; } + + bool IsDefault() const; + + friend SvStream& ReadLineInfo( SvStream& rIStm, LineInfo& rLineInfo ); + friend SvStream& WriteLineInfo( SvStream& rOStm, const LineInfo& rLineInfo ); + + // helper to get decomposed polygon data with the LineInfo applied. The source + // hairline polygon is given in io_rLinePolyPolygon. Both given polygons may + // contain results; e.g. when no fat line but DashDot is defined, the result will + // be in io_rLinePolyPolygon while o_rFillPolyPolygon will be empty. When fat line + // is defined, it will be vice-versa. If none is defined, io_rLinePolyPolygon will + // not be changed (but o_rFillPolyPolygon will be freed) + void applyToB2DPolyPolygon( + basegfx::B2DPolyPolygon& io_rLinePolyPolygon, + basegfx::B2DPolyPolygon& o_rFillPolyPolygon) const; + +private: + o3tl::cow_wrapper< ImplLineInfo > mpImplLineInfo; +}; + +#endif // INCLUDED_VCL_LINEINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lok.hxx b/include/vcl/lok.hxx new file mode 100644 index 000000000..7fc5479a2 --- /dev/null +++ b/include/vcl/lok.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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_LOK_HXX +#define INCLUDED_VCL_LOK_HXX + +#include <sal/config.h> +#include <vcl/dllapi.h> +#include <LibreOfficeKit/LibreOfficeKitTypes.h> + +namespace vcl +{ +namespace lok +{ +bool VCL_DLLPUBLIC isUnipoll(); +void VCL_DLLPUBLIC registerPollCallbacks(LibreOfficeKitPollCallback pPollCallback, + LibreOfficeKitWakeCallback pWakeCallback, void* pData); +void VCL_DLLPUBLIC unregisterPollCallbacks(); +} +} + +#endif // INCLUDE_VCL_LOK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/longcurr.hxx b/include/vcl/longcurr.hxx new file mode 100644 index 000000000..6732a184b --- /dev/null +++ b/include/vcl/longcurr.hxx @@ -0,0 +1,102 @@ +/* -*- 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_LONGCURR_HXX +#define INCLUDED_VCL_LONGCURR_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <tools/bigint.hxx> +#include <vcl/field.hxx> + +class LocaleDataWrapper; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) LongCurrencyFormatter : public FormatterBase +{ +public: + virtual ~LongCurrencyFormatter() override; + + virtual void Reformat() override; + virtual void ReformatAll() override; + + void SetUseThousandSep( bool b ); + bool IsUseThousandSep() const { return mbThousandSep; } + + void SetCurrencySymbol( const OUString& rStr ); + OUString const & GetCurrencySymbol() const; + + void SetMin(const BigInt& rNewMin); + const BigInt& GetMin() const { return mnMin; } + void SetMax(const BigInt& rNewMax); + const BigInt& GetMax() const { return mnMax; } + + void SetDecimalDigits( sal_uInt16 nDigits ); + sal_uInt16 GetDecimalDigits() const { return mnDecimalDigits;} + void SetValue(const BigInt& rNewValue); + void SetUserValue( BigInt nNewValue ); + BigInt GetValue() const; + +protected: + BigInt mnLastValue; + BigInt mnMin; + BigInt mnMax; + + LongCurrencyFormatter(Edit* pEdit); +private: + friend bool ImplLongCurrencyReformat( const OUString&, BigInt const &, BigInt const &, sal_uInt16, const LocaleDataWrapper&, OUString&, LongCurrencyFormatter const & ); + SAL_DLLPRIVATE void ImpInit(); + + OUString maCurrencySymbol; + sal_uInt16 mnDecimalDigits; + bool mbThousandSep; + +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) LongCurrencyField final : public SpinField, public LongCurrencyFormatter +{ + friend void ImplNewLongCurrencyFieldValue(LongCurrencyField*, const BigInt&); + +private: + BigInt mnSpinSize; + BigInt mnFirst; + BigInt mnLast; + +public: + LongCurrencyField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + + void Modify() override; + void Up() override; + void Down() override; + void First() override; + void Last() override; + + void SetFirst(const BigInt& rNewFirst ) { mnFirst = rNewFirst; } + const BigInt& GetFirst() const { return mnFirst; } + void SetLast(const BigInt& rNewLast ) { mnLast = rNewLast; } + const BigInt& GetLast() const { return mnLast; } + void SetSpinSize(const BigInt& rNewSize) { mnSpinSize = rNewSize; } + const BigInt& GetSpinSize() const { return mnSpinSize; } +}; + +#endif // INCLUDED_VCL_LONGCURR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/lstbox.hxx b/include/vcl/lstbox.hxx new file mode 100644 index 000000000..d72de5b0b --- /dev/null +++ b/include/vcl/lstbox.hxx @@ -0,0 +1,269 @@ +/* -*- 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_LSTBOX_HXX +#define INCLUDED_VCL_LSTBOX_HXX + +#include <config_options.h> +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> + +class DataChangedEvent; +class NotifyEvent; +class UserDrawEvent; + +#define LISTBOX_APPEND (SAL_MAX_INT32) +#define LISTBOX_ENTRY_NOTFOUND (SAL_MAX_INT32) +#define LISTBOX_MAX_ENTRIES (SAL_MAX_INT32 - 1) + +// the following defines can be used for the SetEntryFlags() +// and GetEntryFlags() methods + +// !! Do not use these flags for user data as they are reserved !! +// !! to change the internal behaviour of the ListBox implementation !! +// !! for specific entries. !! + +enum class ListBoxEntryFlags +{ + NONE = 0x0000, +/** this flag disables a selection of an entry completely. It is not + possible to select such entries either from the user interface + nor from the ListBox methods. Cursor traveling is handled correctly. + This flag can be used to add titles to a ListBox. +*/ + DisableSelection = 0x0001, + +/** this flag can be used to make an entry multiline capable + A normal entry is single line and will therefore be clipped + at the right listbox border. Setting this flag enables + word breaks for the entry text. +*/ + MultiLine = 0x0002, + +/** this flags lets the item be drawn disabled (e.g. in grey text) + usage only guaranteed with ListBoxEntryFlags::DisableSelection +*/ + DrawDisabled = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags<ListBoxEntryFlags> : is_typed_flags<ListBoxEntryFlags, 0x0007> {}; +} + +class Image; +class ImplListBox; +class ImplListBoxFloatingWindow; +class ImplBtn; +class ImplWin; +class ImplListBoxWindow; + +/// A widget used to choose from a list of items and which has no entry. +class VCL_DLLPUBLIC ListBox : public Control +{ +private: + VclPtr<ImplListBox> mpImplLB; + VclPtr<ImplListBoxFloatingWindow> mpFloatWin; + VclPtr<ImplWin> mpImplWin; + VclPtr<ImplBtn> mpBtn; + sal_uInt16 mnDDHeight; + sal_Int32 mnSaveValue; + sal_Int32 m_nMaxWidthChars; + Link<ListBox&,void> maSelectHdl; + sal_uInt16 mnLineCount; + + bool mbDDAutoSize : 1; + +private: + SAL_DLLPRIVATE void ImplInitListBoxData(); + + DECL_DLLPRIVATE_LINK( ImplSelectHdl, LinkParamNone*, void ); + DECL_DLLPRIVATE_LINK( ImplScrollHdl, ImplListBox*, void ); + DECL_DLLPRIVATE_LINK( ImplCancelHdl, LinkParamNone*, void ); + DECL_DLLPRIVATE_LINK( ImplDoubleClickHdl, ImplListBoxWindow*, void ); + DECL_DLLPRIVATE_LINK( ImplPopupModeEndHdl, FloatingWindow*, void ); + DECL_DLLPRIVATE_LINK( ImplSelectionChangedHdl, sal_Int32, void ); + DECL_DLLPRIVATE_LINK( ImplFocusHdl, sal_Int32, void ); + DECL_DLLPRIVATE_LINK( ImplListItemSelectHdl, LinkParamNone*, void ); + + DECL_DLLPRIVATE_LINK( ImplClickBtnHdl, void*, void ); + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + bool IsDropDownBox() const { return mpFloatWin != nullptr; } + +protected: + explicit ListBox( WindowType nType ); + + virtual void FillLayoutData() const override; + +public: + explicit ListBox( vcl::Window* pParent, WinBits nStyle = WB_BORDER ); + virtual ~ListBox() override; + virtual void dispose() override; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Select(); + void DoubleClick(); + virtual void GetFocus() override; + virtual void LoseFocus() override; + + virtual const Wallpaper& GetDisplayBackground() const override; + + virtual void setPosSizePixel( long nX, long nY, + long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) override; + + tools::Rectangle GetDropDownPosSizePixel() const; + + void AdaptDropDownLineCountToMaximum(); + void SetDropDownLineCount( sal_uInt16 nLines ); + sal_uInt16 GetDropDownLineCount() const; + + void EnableAutoSize( bool bAuto ); + bool IsAutoSizeEnabled() const { return mbDDAutoSize; } + + sal_Int32 InsertEntry( const OUString& rStr, sal_Int32 nPos = LISTBOX_APPEND ); + sal_Int32 InsertEntry( const OUString& rStr, const Image& rImage, sal_Int32 nPos = LISTBOX_APPEND ); + void RemoveEntry( sal_Int32 nPos ); + + void Clear(); + + sal_Int32 GetEntryPos( const OUString& rStr ) const; + Image GetEntryImage( sal_Int32 nPos ) const; + OUString GetEntry( sal_Int32 nPos ) const; + sal_Int32 GetEntryCount() const; + + void SelectEntry( const OUString& rStr, bool bSelect = true ); + void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ); + void SelectEntriesPos( const std::vector<sal_Int32>& rPositions, bool bSelect = true ); + + sal_Int32 GetSelectedEntryCount() const; + OUString GetSelectedEntry( sal_Int32 nSelIndex = 0 ) const; + sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex = 0 ) const; + + bool IsEntryPosSelected( sal_Int32 nPos ) const; + void SetNoSelection(); + + void SetEntryData( sal_Int32 nPos, void* pNewData ); + void* GetEntryData( sal_Int32 nPos ) const; + + /** this methods stores a combination of flags from the + ListBoxEntryFlags::* defines at the given entry. + See description of the possible ListBoxEntryFlags::* flags + for details. + Do not use these flags for user data as they are reserved + to change the internal behaviour of the ListBox implementation + for specific entries. + */ + void SetEntryFlags( sal_Int32 nPos, ListBoxEntryFlags nFlags ); + + void SetTopEntry( sal_Int32 nPos ); + sal_Int32 GetTopEntry() const; + + /** + * Removes existing separators, and sets the position of the + * one and only separator. + */ + void SetSeparatorPos( sal_Int32 n ); + /** + * Gets the position of the separator which was added first. + * Returns LISTBOX_ENTRY_NOTFOUND if there is no separator. + */ + sal_Int32 GetSeparatorPos() const; + + /** + * Adds a new separator at the given position n. + */ + void AddSeparator( sal_Int32 n ); + + bool IsTravelSelect() const; + bool IsInDropDown() const; + void ToggleDropDown(); + + void EnableMultiSelection( bool bMulti, bool bStackSelection ); + void EnableMultiSelection( bool bMulti ); + bool IsMultiSelectionEnabled() const; + + void SetReadOnly( bool bReadOnly = true ); + bool IsReadOnly() const; + + tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const; + + void SetSelectHdl( const Link<ListBox&,void>& rLink ) { maSelectHdl = rLink; } + + Size CalcSubEditSize() const; //size of area inside lstbox, i.e. no scrollbar/dropdown + Size CalcMinimumSize() const; //size of lstbox area, i.e. including scrollbar/dropdown + virtual Size GetOptimalSize() const override; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + sal_uInt16 GetDisplayLineCount() const; + + void EnableMirroring(); + + /** checks whether a certain point lies within the bounds of + a listbox item and returns the item as well as the character position + the point is at. + + <p>If the point is inside an item the item pos is put into <code>rPos</code> and + the item-relative character index is returned. If the point is not inside + an item -1 is returned and rPos is unchanged.</p> + + @param rPoint + tells the point for which an item is requested. + + @param rPos + gets the item at the specified point <code>rPoint</code> + + @returns + the item-relative character index at point <code>rPos</code> or -1 + if no item is at that point. + */ + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const; + + void setMaxWidthChars(sal_Int32 nWidth); + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + virtual FactoryFunction GetUITestFactory() const override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MultiListBox final : public ListBox +{ +public: + explicit MultiListBox( vcl::Window* pParent, WinBits nStyle ); + +}; + +#endif // INCLUDED_VCL_LSTBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/mapmod.hxx b/include/vcl/mapmod.hxx new file mode 100644 index 000000000..e6c96048c --- /dev/null +++ b/include/vcl/mapmod.hxx @@ -0,0 +1,88 @@ +/* -*- 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_MAPMOD_HXX +#define INCLUDED_VCL_MAPMOD_HXX + +#include <vcl/dllapi.h> +#include <tools/mapunit.hxx> +#include <o3tl/cow_wrapper.hxx> + +#include <ostream> + +class Point; +class Fraction; +class SvStream; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC MapMode +{ + friend class OutputDevice; + +public: + struct SAL_DLLPRIVATE ImplMapMode; + + MapMode(); + MapMode( const MapMode& rMapMode ); + explicit MapMode( MapUnit eUnit ); + MapMode( MapUnit eUnit, const Point& rLogicOrg, + const Fraction& rScaleX, const Fraction& rScaleY ); + ~MapMode(); + + void SetMapUnit( MapUnit eUnit ); + MapUnit GetMapUnit() const; + + void SetOrigin( const Point& rOrigin ); + const Point& GetOrigin() const; + + void SetScaleX( const Fraction& rScaleX ); + const Fraction& GetScaleX() const; + void SetScaleY( const Fraction& rScaleY ); + const Fraction& GetScaleY() const; + + MapMode& operator=( const MapMode& rMapMode ); + MapMode& operator=( MapMode&& rMapMode ); + bool operator==( const MapMode& rMapMode ) const; + bool operator!=( const MapMode& rMapMode ) const + { return !(MapMode::operator==( rMapMode )); } + bool IsDefault() const; + + friend SvStream& ReadMapMode( SvStream& rIStm, MapMode& rMapMode ); + friend SvStream& WriteMapMode( SvStream& rOStm, const MapMode& rMapMode ); + + // tdf#117984 needs to be thread-safe due to being used e.g. in Bitmaps + // vcl::ScopedBitmapAccess in parallelized 3D renderer + typedef o3tl::cow_wrapper< ImplMapMode, o3tl::ThreadSafeRefCountingPolicy > ImplType; + +private: + ImplType mpImplMapMode; + + SAL_DLLPRIVATE bool IsSimple() const; +}; + +template<typename charT, typename traits> +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & rStream, const MapMode& rMode) +{ + rStream << "MapMode(" << static_cast<unsigned>(rMode.GetMapUnit()) << ",(" << rMode.GetScaleX() << "," << rMode.GetScaleY() << ")@(" << rMode.GetOrigin() << "))"; + return rStream; +} + +#endif // INCLUDED_VCL_MAPMOD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx new file mode 100644 index 000000000..bea9e2a39 --- /dev/null +++ b/include/vcl/menu.hxx @@ -0,0 +1,539 @@ +/* -*- 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_MENU_HXX +#define INCLUDED_VCL_MENU_HXX + +#include <memory> +#include <vcl/vclenum.hxx> +#include <tools/link.hxx> +#include <vcl/dllapi.h> +#include <vcl/keycod.hxx> +#include <vcl/vclreferencebase.hxx> +#include <vcl/vclevent.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <list> + +class OutputDevice; +struct ImplSVEvent; +struct MenuItemData; +class Point; +class Size; +namespace tools { class Rectangle; } +class Menu; +class MenuItemList; +class Image; +class PopupMenu; +class KeyEvent; +class CommandEvent; +class MenuFloatingWindow; +class SalMenu; +class MenuBarWindow; +struct SystemMenuData; +enum class FloatWinPopupFlags; + +namespace com::sun::star::accessibility { class XAccessible; } +namespace com::sun::star::frame { class XFrame; } + +namespace vcl +{ +class Window; +struct MenuLayoutData; +typedef OutputDevice RenderContext; // same as in include/vcl/outdev.hxx +class ILibreOfficeKitNotifier; +} + +constexpr sal_uInt16 MENU_APPEND = 0xFFFF; +constexpr sal_uInt16 MENU_ITEM_NOTFOUND = 0xFFFF; + +// Must match the definitions in css::awt::PopupMenuDirection.idl +enum class PopupMenuFlags +{ + NONE = 0x0000, + ExecuteDown = 0x0001, + ExecuteUp = 0x0002, + ExecuteLeft = 0x0004, + ExecuteRight = 0x0008, + NoMouseUpClose = 0x0010, +//If there isn't enough space to put the menu where it wants +//to go, then they will be autoplaced. Toggle this bit +//on to force menus to be placed either above or below +//the starting rectangle and shrunk to fit and then scroll rather than place +//the menu beside that rectangle + NoHorzPlacement = 0x0020, +}; + +namespace o3tl +{ + template<> struct typed_flags<PopupMenuFlags> : is_typed_flags<PopupMenuFlags, 0x003f> {}; +} + +enum class MenuFlags +{ + NONE = 0x0000, + NoAutoMnemonics = 0x0001, + HideDisabledEntries = 0x0002, + // overrides default hiding of disabled entries in popup menus + AlwaysShowDisabledEntries = 0x0004, +}; + +namespace o3tl +{ + template<> struct typed_flags<MenuFlags> : is_typed_flags<MenuFlags, 0x0007> {}; +} + +/// Invalid menu item id +constexpr auto ITEMPOS_INVALID = 0xFFFF; + +struct ImplMenuDelData +{ + ImplMenuDelData* mpNext; + VclPtr<const Menu> mpMenu; + + explicit ImplMenuDelData( const Menu* ); + ~ImplMenuDelData(); + + bool isDeleted() const { return mpMenu == nullptr; } +}; + +typedef void (*MenuUserDataReleaseFunction)(void*); + +class VCL_DLLPUBLIC Menu : public VclReferenceBase +{ + friend class MenuBar; + friend class MenuBarWindow; + friend class MenuButton; + friend class MenuFloatingWindow; + friend class PopupMenu; + friend class SystemWindow; + friend struct ImplMenuDelData; +private: + ImplMenuDelData* mpFirstDel; + std::unique_ptr<MenuItemList> pItemList; // list with MenuItems + VclPtr<Menu> pStartedFrom; + VclPtr<vcl::Window> pWindow; + + Link<Menu*, bool> aActivateHdl; // Active-Handler + Link<Menu*, bool> aDeactivateHdl; // Deactivate-Handler + Link<Menu*, bool> aSelectHdl; // Select-Handler + + std::list<Link<VclMenuEvent&,void> > maEventListeners; + + OUString aTitleText; // PopupMenu text + sal_uInt16 nTitleHeight; + + ImplSVEvent* nEventId; + sal_uInt16 mnHighlightedItemPos; // for native menus: keeps track of the highlighted item + MenuFlags nMenuFlags; + sal_uInt16 nSelectedId; + OString sSelectedIdent; + + // for output: + sal_uInt16 nImgOrChkPos; + sal_uInt16 nTextPos; + + bool bCanceled : 1; ///< Terminated during a callback + bool bInCallback : 1; ///< In Activate/Deactivate + bool bKilled : 1; ///< Killed + + css::uno::Reference<css::accessibility::XAccessible > mxAccessible; + mutable std::unique_ptr<vcl::MenuLayoutData> mpLayoutData; + std::unique_ptr<SalMenu> mpSalMenu; + +protected: + SAL_DLLPRIVATE Menu* ImplGetStartMenu(); + SAL_DLLPRIVATE Menu* ImplFindSelectMenu(); + SAL_DLLPRIVATE Menu* ImplFindMenu( sal_uInt16 nId ); + SAL_DLLPRIVATE Size ImplCalcSize( vcl::Window* pWin ); + SAL_DLLPRIVATE bool ImplIsVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE bool ImplCurrentlyHiddenOnGUI(sal_uInt16 nPos) const; + SAL_DLLPRIVATE bool ImplIsSelectable( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetVisibleItemCount() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const; + SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize, + sal_uInt16 nBorder, long nOffY = 0, MenuItemData const * pThisDataOnly = nullptr, + bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const; + SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const tools::Rectangle& rRect) const; + SAL_DLLPRIVATE void ImplSelect(); + SAL_DLLPRIVATE void ImplCallHighlight( sal_uInt16 nHighlightItem ); + SAL_DLLPRIVATE void ImplCallEventListeners( VclEventId nEvent, sal_uInt16 nPos ); + DECL_DLLPRIVATE_LINK(ImplCallSelect, void*, void ); + + SAL_DLLPRIVATE void ImplFillLayoutData() const; + SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu.get(); } + SAL_DLLPRIVATE OUString ImplGetHelpText( sal_uInt16 nItemId ) const; + + // returns native check and option menu symbol height in rCheckHeight and rRadioHeight + // return value is maximum width and height of checkboxes and radiobuttons + SAL_DLLPRIVATE Size ImplGetNativeCheckAndRadioSize(vcl::RenderContext const & rRenderContext, long& rCheckHeight, long& rRadioHeight) const; + + // returns native submenu arrow size and spacing from right border + // return value is whether it's supported natively + SAL_DLLPRIVATE static bool ImplGetNativeSubmenuArrowSize(vcl::RenderContext const & rRenderContext, Size& rArrowSize, long& rArrowSpacing); + + SAL_DLLPRIVATE void ImplAddDel( ImplMenuDelData &rDel ); + SAL_DLLPRIVATE void ImplRemoveDel( ImplMenuDelData &rDel ); + + SAL_DLLPRIVATE MenuItemData* NbcInsertItem(sal_uInt16 nId, MenuItemBits nBits, + const OUString& rStr, Menu* pMenu, + size_t nPos, const OString &rIdent); + + /// Close the 'pStartedFrom' menu window. + virtual void ClosePopup(Menu* pMenu) = 0; + + /// Forward the KeyInput call to the MenuBar. + virtual void MenuBarKeyInput(const KeyEvent& rEvent); + +public: + SAL_DLLPRIVATE void ImplKillLayoutData() const; + + SAL_DLLPRIVATE vcl::Window* ImplGetWindow() const { return pWindow; } +#if defined(MACOSX) + void ImplSelectWithStart( Menu* pStartMenu = nullptr ); +#endif + +protected: + + /** The Menu constructor is protected. + + The callers are supposed to instantiate either PopupMenu or MenuBar, but + not a Menu directly. + */ + Menu(); + +public: + virtual ~Menu() override; + virtual void dispose() override; + + void Activate(); + void Deactivate(); + virtual void Select(); + + void InsertItem(sal_uInt16 nItemId, const OUString& rStr, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(sal_uInt16 nItemId, const Image& rImage, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(sal_uInt16 nItemId, + const OUString& rString, const Image& rImage, + MenuItemBits nItemBits = MenuItemBits::NONE, + const OString &rIdent = OString(), + sal_uInt16 nPos = MENU_APPEND); + void InsertItem(const OUString& rCommand, + const css::uno::Reference<css::frame::XFrame>& rFrame); + void InsertSeparator(const OString &rIdent = OString(), sal_uInt16 nPos = MENU_APPEND); + void RemoveItem( sal_uInt16 nPos ); + void Clear(); + + void CreateAutoMnemonics(); + + void SetMenuFlags( MenuFlags nFlags ) { nMenuFlags = nFlags; } + MenuFlags GetMenuFlags() const { return nMenuFlags; } + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId(sal_uInt16 nPos) const; + sal_uInt16 GetItemId(const OString &rIdent) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + OString GetItemIdent(sal_uInt16 nItemId) const; + MenuItemType GetItemType( sal_uInt16 nPos ) const; + sal_uInt16 GetCurItemId() const { return nSelectedId;} + OString const & GetCurItemIdent() const { return sSelectedIdent; } + void SetItemBits( sal_uInt16 nItemId, MenuItemBits nBits ); + MenuItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetUserValue(sal_uInt16 nItemId, void* nUserValue, MenuUserDataReleaseFunction aFunc=nullptr); + void* GetUserValue(sal_uInt16 nItemId) const; + + void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ); + PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const; + + void SetAccelKey( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); + vcl::KeyCode GetAccelKey( sal_uInt16 nItemId ) const; + + void CheckItem( sal_uInt16 nItemId, bool bCheck = true ); + void CheckItem( const OString &rIdent, bool bCheck = true ); + bool IsItemChecked( sal_uInt16 nItemId ) const; + + virtual void SelectItem(sal_uInt16 nItemId) = 0; + + void EnableItem( sal_uInt16 nItemId, bool bEnable = true ); + void EnableItem(const OString &rIdent, bool bEnable = true) + { + EnableItem(GetItemId(rIdent), bEnable); + } + bool IsItemEnabled( sal_uInt16 nItemId ) const; + + void ShowItem( sal_uInt16 nItemId, bool bVisible = true ); + void HideItem( sal_uInt16 nItemId ) { ShowItem( nItemId, false ); } + + bool IsItemPosVisible( sal_uInt16 nItemPos ) const; + bool IsMenuVisible() const; + virtual bool IsMenuBar() const = 0; + + void RemoveDisabledEntries( bool bCheckPopups = true, bool bRemoveEmptyPopups = false ); + + void UpdateNativeMenu(); + + void SetItemText( sal_uInt16 nItemId, const OUString& rStr ); + OUString GetItemText( sal_uInt16 nItemId ) const; + + void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemImage( sal_uInt16 nItemId ) const; + + void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); + OUString GetItemCommand( sal_uInt16 nItemId ) const; + + void SetHelpText( sal_uInt16 nItemId, const OUString& rString ); + OUString GetHelpText( sal_uInt16 nItemId ) const; + + void SetTipHelpText( sal_uInt16 nItemId, const OUString& rString ); + OUString GetTipHelpText( sal_uInt16 nItemId ) const; + + void SetHelpCommand( sal_uInt16 nItemId, const OUString& rString ); + OUString GetHelpCommand( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); + OString GetHelpId( sal_uInt16 nItemId ) const; + + void SetActivateHdl( const Link<Menu *, bool>& rLink ) + { + aActivateHdl = rLink; + } + + void SetDeactivateHdl( const Link<Menu *, bool>& rLink ) + { + aDeactivateHdl = rLink; + } + + void SetSelectHdl( const Link<Menu*,bool>& rLink ) + { + aSelectHdl = rLink; + } + + sal_uInt16 GetTitleHeight() const + { + return nTitleHeight; + } + + void AddEventListener( const Link<VclMenuEvent&,void>& rEventListener ); + void RemoveEventListener( const Link<VclMenuEvent&,void>& rEventListener ); + + Menu& operator =( const Menu& rMenu ); + + // for menu functions + MenuItemList* GetItemList() const + { + return pItemList.get(); + } + + // returns the system's menu handle if native menus are supported + // pData must point to a SystemMenuData structure + void GetSystemMenuData( SystemMenuData* pData ) const; + + // accessibility helpers + + // returns the bounding box for the character at index nIndex + // where nIndex is relative to the starting index of the item + // with id nItemId (in coordinates of the displaying window) + tools::Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ) const; + // -1 is returned if no character is at that point + // if an index is found the corresponding item id is filled in (else 0) + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ) const; + // returns the bounding rectangle for an item at pos nItemPos + tools::Rectangle GetBoundingRectangle( sal_uInt16 nItemPos ) const; + + css::uno::Reference<css::accessibility::XAccessible> GetAccessible(); + void SetAccessible(const css::uno::Reference<css::accessibility::XAccessible >& rxAccessible); + + // gets the activation key of the specified item + KeyEvent GetActivationKey( sal_uInt16 nItemId ) const; + + vcl::Window* GetWindow() const { return pWindow; } + + OUString GetAccessibleName( sal_uInt16 nItemId ) const; + + // returns whether the item a position nItemPos is highlighted or not. + bool IsHighlighted( sal_uInt16 nItemPos ) const; + + void HighlightItem( sal_uInt16 nItemPos ); + void DeHighlight() { HighlightItem( 0xFFFF ); } // MENUITEMPOS_INVALID + + bool HandleMenuCommandEvent(Menu *pMenu, sal_uInt16 nEventId) const; + bool HandleMenuActivateEvent(Menu *pMenu) const; + bool HandleMenuDeActivateEvent(Menu *pMenu) const; +}; + +class VCL_DLLPUBLIC MenuBar : public Menu +{ + Link<void*,void> maCloseHdl; + bool mbCloseBtnVisible : 1; + bool mbFloatBtnVisible : 1; + bool mbHideBtnVisible : 1; + bool mbDisplayable : 1; + + friend class Application; + friend class Menu; + friend class MenuBarWindow; + friend class MenuFloatingWindow; + friend class SystemWindow; + + SAL_DLLPRIVATE static VclPtr<vcl::Window> ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu); + SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete); + SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent); + SAL_DLLPRIVATE bool ImplHandleCmdEvent(const CommandEvent& rCEvent); + +protected: + + /// Return the MenuBarWindow. + MenuBarWindow* getMenuBarWindow(); + +public: + MenuBar(); + MenuBar( const MenuBar& rMenu ); + virtual ~MenuBar() override; + virtual void dispose() override; + + MenuBar& operator =( const MenuBar& rMenu ); + + virtual bool IsMenuBar() const override { return true; } + + /// Close the 'pStartedFrom' menu window. + virtual void ClosePopup(Menu* pMenu) override; + + /// Forward the KeyInput call to the MenuBar. + virtual void MenuBarKeyInput(const KeyEvent& rEvent) override; + + void ShowCloseButton( bool bShow ); + bool HasCloseButton() const { return mbCloseBtnVisible; } + bool HasFloatButton() const { return mbFloatBtnVisible; } + bool HasHideButton() const { return mbHideBtnVisible; } + void ShowButtons( bool bClose, bool bFloat, bool bHide ); + + virtual void SelectItem(sal_uInt16 nId) override; + bool HandleMenuHighlightEvent(Menu *pMenu, sal_uInt16 nEventId) const; + bool HandleMenuButtonEvent(sal_uInt16 nEventId); + + void SetCloseButtonClickHdl( const Link<void*,void>& rLink ) { maCloseHdl = rLink; } + const Link<void*,void>& GetCloseButtonClickHdl() const { return maCloseHdl; } + + // - by default a menubar is displayable + // - if a menubar is not displayable, its MenuBarWindow will never be shown + // and it will be hidden if it was visible before + // - note: if a menubar is displayable, this does not necessarily mean that it is currently visible + void SetDisplayable( bool bDisplayable ); + bool IsDisplayable() const { return mbDisplayable; } + + struct MenuBarButtonCallbackArg + { + sal_uInt16 nId; // Id of the button + bool bHighlight; // highlight on/off + }; + // add an arbitrary button to the menubar (will appear next to closer) + // passed link will be call with a MenuBarButtonCallbackArg on press + // passed string will be set as tooltip + sal_uInt16 AddMenuBarButton( const Image&, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>&, const OUString& ); + // set the highlight link for additional button with ID nId + // highlight link will be called with a MenuBarButtonHighlightArg + // the bHighlight member of that struct shall contain the new state + void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link<MenuBar::MenuBarButtonCallbackArg&,bool>& ); + // returns the rectangle occupied by the additional button named nId + // coordinates are relative to the systemwindow the menubar is attached to + // if the menubar is unattached an empty rectangle is returned + tools::Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId ); + void RemoveMenuBarButton( sal_uInt16 nId ); + void LayoutChanged(); + // get the height of the menubar, return the native menubar height if that is active or the vcl + // one if not + int GetMenuBarHeight() const; +}; + +inline MenuBar& MenuBar::operator=( const MenuBar& rMenu ) +{ + Menu::operator=(rMenu); + return *this; +} + +class VCL_DLLPUBLIC PopupMenu : public Menu +{ + friend class Menu; + friend class MenuFloatingWindow; + friend class MenuBarWindow; + friend struct MenuItemData; + +private: + const vcl::ILibreOfficeKitNotifier* mpLOKNotifier; ///< To emit the LOK callbacks eg. for dialog tunneling. + + SAL_DLLPRIVATE MenuFloatingWindow * ImplGetFloatingWindow() const; + +protected: + SAL_DLLPRIVATE sal_uInt16 ImplExecute( const VclPtr<vcl::Window>& pW, const tools::Rectangle& rRect, FloatWinPopupFlags nPopupModeFlags, Menu* pSFrom, bool bPreSelectFirst ); + SAL_DLLPRIVATE void ImplFlushPendingSelect(); + SAL_DLLPRIVATE long ImplCalcHeight( sal_uInt16 nEntries ) const; + SAL_DLLPRIVATE sal_uInt16 ImplCalcVisEntries( long nMaxHeight, sal_uInt16 nStartEntry, sal_uInt16* pLastVisible = nullptr ) const; + +public: + PopupMenu(); + PopupMenu( const PopupMenu& rMenu ); + virtual ~PopupMenu() override; + + virtual bool IsMenuBar() const override { return false; } + + /// Close the 'pStartedFrom' menu window. + virtual void ClosePopup(Menu* pMenu) override; + + void SetText( const OUString& rTitle ) + { + aTitleText = rTitle; + } + + sal_uInt16 Execute( vcl::Window* pWindow, const Point& rPopupPos ); + sal_uInt16 Execute( vcl::Window* pWindow, const tools::Rectangle& rRect, PopupMenuFlags nFlags = PopupMenuFlags::NONE ); + + // for the TestTool + void EndExecute(); + virtual void SelectItem(sal_uInt16 nId) override; + void SetSelectedEntry( sal_uInt16 nId ); // for use by native submenu only + + static bool IsInExecute(); + static PopupMenu* GetActivePopupMenu(); + + /// Interface to register for dialog / window tunneling. + void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier) + { + mpLOKNotifier = pNotifier; + } + + PopupMenu& operator=( const PopupMenu& rMenu ); +}; + +inline PopupMenu& PopupMenu::operator=( const PopupMenu& rMenu ) +{ + Menu::operator=( rMenu ); + return *this; +} + +#endif // INCLUDED_VCL_MENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/menubtn.hxx b/include/vcl/menubtn.hxx new file mode 100644 index 000000000..609d3d031 --- /dev/null +++ b/include/vcl/menubtn.hxx @@ -0,0 +1,101 @@ +/* -*- 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_MENUBTN_HXX +#define INCLUDED_VCL_MENUBTN_HXX + +#include <config_options.h> +#include <vcl/button.hxx> +#include <vcl/dllapi.h> +#include <memory> + +class Timer; +class PopupMenu; + +class VCL_DLLPUBLIC MenuButton : public PushButton +{ +private: + friend class VclBuilder; + + std::unique_ptr<Timer> mpMenuTimer; + VclPtr<PopupMenu> mpMenu; + VclPtr<Window> mpFloatingWindow; + OString msCurItemIdent; + sal_uInt16 mnCurItemId; + bool mbDelayMenu; + bool mbStartingMenu; + Link<MenuButton*,void> maActivateHdl; + Link<MenuButton*,void> maSelectHdl; + + DECL_DLLPRIVATE_LINK( ImplMenuTimeoutHdl, Timer*, void ); + + MenuButton( const MenuButton & ) = delete; + MenuButton& operator=( const MenuButton & ) = delete; + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + +public: + explicit MenuButton( vcl::Window* pParent, WinBits nStyle = 0 ); + virtual ~MenuButton() override; + virtual void dispose() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + virtual void Activate() override; + virtual void Select(); + + void ExecuteMenu(); + bool InPopupMode() const; + void CancelMenu(); + + //if false then the whole button launches the menu + //if true, then the button has a separator + //where the right portion launches the menu immediately + //where the left portion activates the underlying Button handlers + //before launching the menu in an idle, allowing it to be cancelled + //before being shown + void SetDelayMenu(bool bDelay) { mbDelayMenu = bDelay; } + + void SetPopupMenu(PopupMenu* pNewMenu); + PopupMenu* GetPopupMenu() const { return mpMenu; } + + void SetPopover(Window* pWindow); + + OString const & GetCurItemIdent() const { return msCurItemIdent; } + + void SetActivateHdl( const Link<MenuButton *, void>& rLink ) { maActivateHdl = rLink; } + void SetSelectHdl( const Link<MenuButton *, void>& rLink ) { maSelectHdl = rLink; } +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MenuToggleButton final : public MenuButton +{ +public: + explicit MenuToggleButton( vcl::Window* pParent, WinBits nStyle ); + virtual ~MenuToggleButton() override; + + void SetActive( bool bSel ); +}; + +#endif // INCLUDED_VCL_MENUBTN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx new file mode 100644 index 000000000..fad89ec4b --- /dev/null +++ b/include/vcl/metaact.hxx @@ -0,0 +1,1721 @@ +/* -*- 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_METAACT_HXX +#define INCLUDED_VCL_METAACT_HXX + +#include <config_options.h> +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/gradient.hxx> +#include <vcl/hatch.hxx> +#include <vcl/wall.hxx> +#include <vcl/font.hxx> +#include <tools/poly.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/region.hxx> +#include <vcl/outdevstate.hxx> +#include <vcl/gdimtf.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/lineinfo.hxx> +#include <vcl/metaactiontypes.hxx> +#include <salhelper/simplereferenceobject.hxx> +#include <rtl/ref.hxx> + +class OutputDevice; +class SvStream; +enum class DrawTextFlags; + +struct ImplMetaReadData +{ + rtl_TextEncoding meActualCharSet; + int mnParseDepth; + + ImplMetaReadData() + : meActualCharSet(RTL_TEXTENCODING_ASCII_US) + , mnParseDepth(0) + {} +}; + +struct ImplMetaWriteData +{ + rtl_TextEncoding meActualCharSet; + + ImplMetaWriteData() : + meActualCharSet( RTL_TEXTENCODING_ASCII_US ) + {} +}; + +class VCL_DLLPUBLIC MetaAction : public salhelper::SimpleReferenceObject +{ +private: + MetaActionType mnType; + +protected: + virtual ~MetaAction() override; + +public: + MetaAction(); + explicit MetaAction( MetaActionType nType ); + MetaAction( MetaAction const & ); + + virtual void Execute( OutputDevice* pOut ); + + oslInterlockedCount GetRefCount() const { return m_nCount; } + + virtual rtl::Reference<MetaAction> Clone(); + + virtual void Move( long nHorzMove, long nVertMove ); + virtual void Scale( double fScaleX, double fScaleY ); + + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ); + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ); + + MetaActionType GetType() const { return mnType; } + /** \#i10613# Extracted from Printer::GetPreparedMetaFile. Returns true + if given action requires special transparency handling + */ + virtual bool IsTransparent() const { return false; } + +public: + static MetaAction* ReadMetaAction( SvStream& rIStm, ImplMetaReadData* pData ); +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPixelAction final : public MetaAction +{ +private: + Point maPt; + Color maColor; + +public: + MetaPixelAction(); + MetaPixelAction(MetaPixelAction const &) = default; + MetaPixelAction(MetaPixelAction &&) = default; + MetaPixelAction & operator =(MetaPixelAction const &) = delete; // due to MetaAction + MetaPixelAction & operator =(MetaPixelAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPixelAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaPixelAction( const Point& rPt, const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetPoint() const { return maPt; } + const Color& GetColor() const { return maColor; } +}; + +class SAL_DLLPUBLIC_RTTI MetaPointAction final : public MetaAction +{ +private: + Point maPt; + +public: + MetaPointAction(); + MetaPointAction(MetaPointAction const &) = default; + MetaPointAction(MetaPointAction &&) = default; + MetaPointAction & operator =(MetaPointAction const &) = delete; // due to MetaAction + MetaPointAction & operator =(MetaPointAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPointAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaPointAction( const Point& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetPoint() const { return maPt; } +}; + +class VCL_DLLPUBLIC MetaLineAction final : public MetaAction +{ +private: + + LineInfo maLineInfo; + Point maStartPt; + Point maEndPt; + +public: + MetaLineAction(); + MetaLineAction(MetaLineAction const &) = default; + MetaLineAction(MetaLineAction &&) = default; + MetaLineAction & operator =(MetaLineAction const &) = delete; // due to MetaAction + MetaLineAction & operator =(MetaLineAction &&) = delete; // due to MetaAction +private: + virtual ~MetaLineAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaLineAction( const Point& rStart, const Point& rEnd ); + MetaLineAction( const Point& rStart, const Point& rEnd, + const LineInfo& rLineInfo ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } + const LineInfo& GetLineInfo() const { return maLineInfo; } +}; + +class VCL_DLLPUBLIC MetaRectAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + +public: + MetaRectAction(); + MetaRectAction(MetaRectAction const &) = default; + MetaRectAction(MetaRectAction &&) = default; + MetaRectAction & operator =(MetaRectAction const &) = delete; // due to MetaAction + MetaRectAction & operator =(MetaRectAction &&) = delete; // due to MetaAction +private: + virtual ~MetaRectAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaRectAction( const tools::Rectangle& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaRoundRectAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + sal_uInt32 mnHorzRound; + sal_uInt32 mnVertRound; + +public: + MetaRoundRectAction(); + MetaRoundRectAction(MetaRoundRectAction const &) = default; + MetaRoundRectAction(MetaRoundRectAction &&) = default; + MetaRoundRectAction & operator =(MetaRoundRectAction const &) = delete; // due to MetaAction + MetaRoundRectAction & operator =(MetaRoundRectAction &&) = delete; // due to MetaAction +private: + virtual ~MetaRoundRectAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaRoundRectAction( const tools::Rectangle& rRect, + sal_uInt32 nHorzRound, sal_uInt32 nVertRound ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + sal_uInt32 GetHorzRound() const { return mnHorzRound; } + sal_uInt32 GetVertRound() const { return mnVertRound; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaEllipseAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + +public: + MetaEllipseAction(); + MetaEllipseAction(MetaEllipseAction const &) = default; + MetaEllipseAction(MetaEllipseAction &&) = default; + MetaEllipseAction & operator =(MetaEllipseAction const &) = delete; // due to MetaAction + MetaEllipseAction & operator =(MetaEllipseAction &&) = delete; // due to MetaAction +private: + virtual ~MetaEllipseAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaEllipseAction( const tools::Rectangle& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaArcAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + Point maStartPt; + Point maEndPt; + +public: + MetaArcAction(); + MetaArcAction(MetaArcAction const &) = default; + MetaArcAction(MetaArcAction &&) = default; + MetaArcAction & operator =(MetaArcAction const &) = delete; // due to MetaAction + MetaArcAction & operator =(MetaArcAction &&) = delete; // due to MetaAction +private: + virtual ~MetaArcAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaArcAction( const tools::Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPieAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + Point maStartPt; + Point maEndPt; + +public: + MetaPieAction(); + MetaPieAction(MetaPieAction const &) = default; + MetaPieAction(MetaPieAction &&) = default; + MetaPieAction & operator =(MetaPieAction const &) = delete; // due to MetaAction + MetaPieAction & operator =(MetaPieAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPieAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaPieAction( const tools::Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaChordAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + Point maStartPt; + Point maEndPt; + +public: + MetaChordAction(); + MetaChordAction(MetaChordAction const &) = default; + MetaChordAction(MetaChordAction &&) = default; + MetaChordAction & operator =(MetaChordAction const &) = delete; // due to MetaAction + MetaChordAction & operator =(MetaChordAction &&) = delete; // due to MetaAction +private: + virtual ~MetaChordAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaChordAction( const tools::Rectangle& rRect, + const Point& rStart, const Point& rEnd ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const Point& GetStartPoint() const { return maStartPt; } + const Point& GetEndPoint() const { return maEndPt; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPolyLineAction final : public MetaAction +{ +private: + + LineInfo maLineInfo; + tools::Polygon maPoly; + +public: + MetaPolyLineAction(); + MetaPolyLineAction(MetaPolyLineAction const &) = default; + MetaPolyLineAction(MetaPolyLineAction &&) = default; + MetaPolyLineAction & operator =(MetaPolyLineAction const &) = delete; // due to MetaAction + MetaPolyLineAction & operator =(MetaPolyLineAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPolyLineAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaPolyLineAction( const tools::Polygon& ); + explicit MetaPolyLineAction( const tools::Polygon&, const LineInfo& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Polygon& GetPolygon() const { return maPoly; } + const LineInfo& GetLineInfo() const { return maLineInfo; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPolygonAction final : public MetaAction +{ +private: + + tools::Polygon maPoly; + +public: + MetaPolygonAction(); + MetaPolygonAction(MetaPolygonAction const &) = default; + MetaPolygonAction(MetaPolygonAction &&) = default; + MetaPolygonAction & operator =(MetaPolygonAction const &) = delete; // due to MetaAction + MetaPolygonAction & operator =(MetaPolygonAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPolygonAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaPolygonAction( const tools::Polygon& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Polygon& GetPolygon() const { return maPoly; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPolyPolygonAction final : public MetaAction +{ +private: + + tools::PolyPolygon maPolyPoly; + +public: + MetaPolyPolygonAction(); + MetaPolyPolygonAction(MetaPolyPolygonAction const &) = default; + MetaPolyPolygonAction(MetaPolyPolygonAction &&) = default; + MetaPolyPolygonAction & operator =(MetaPolyPolygonAction const &) = delete; // due to MetaAction + MetaPolyPolygonAction & operator =(MetaPolyPolygonAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPolyPolygonAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaPolyPolygonAction( const tools::PolyPolygon& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } +}; + +class SAL_DLLPUBLIC_RTTI MetaTextAction final : public MetaAction +{ +private: + + Point maPt; + OUString maStr; + sal_Int32 mnIndex; + sal_Int32 mnLen; + +public: + MetaTextAction(); + MetaTextAction(MetaTextAction const &) = default; + MetaTextAction(MetaTextAction &&) = default; + MetaTextAction & operator =(MetaTextAction const &) = delete; // due to MetaAction + MetaTextAction & operator =(MetaTextAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTextAction( const Point& rPt, const OUString& rStr, + sal_Int32 nIndex, sal_Int32 nLen ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetPoint() const { return maPt; } + const OUString& GetText() const { return maStr; } + sal_Int32 GetIndex() const { return mnIndex; } + sal_Int32 GetLen() const { return mnLen; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextArrayAction final : public MetaAction +{ +private: + + Point maStartPt; + OUString maStr; + std::unique_ptr<long[]> + mpDXAry; + sal_Int32 mnIndex; + sal_Int32 mnLen; + + virtual ~MetaTextArrayAction() override; + +public: + MetaTextArrayAction(); + MetaTextArrayAction( const MetaTextArrayAction& rAction ); + MetaTextArrayAction( const Point& rStartPt, const OUString& rStr, + const long* pDXAry, sal_Int32 nIndex, + sal_Int32 nLen ); + + virtual void Execute( OutputDevice* pOut ) override; + + virtual rtl::Reference<MetaAction> Clone() override; + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + const Point& GetPoint() const { return maStartPt; } + const OUString& GetText() const { return maStr; } + sal_Int32 GetIndex() const { return mnIndex; } + sal_Int32 GetLen() const { return mnLen; } + long* GetDXArray() const { return mpDXAry.get(); } +}; + +class SAL_DLLPUBLIC_RTTI MetaStretchTextAction final : public MetaAction +{ +private: + + Point maPt; + OUString maStr; + sal_uInt32 mnWidth; + sal_Int32 mnIndex; + sal_Int32 mnLen; + +public: + MetaStretchTextAction(); + MetaStretchTextAction(MetaStretchTextAction const &) = default; + MetaStretchTextAction(MetaStretchTextAction &&) = default; + MetaStretchTextAction & operator =(MetaStretchTextAction const &) = delete; // due to MetaAction + MetaStretchTextAction & operator =(MetaStretchTextAction &&) = delete; // due to MetaAction +private: + virtual ~MetaStretchTextAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaStretchTextAction( const Point& rPt, sal_uInt32 nWidth, + const OUString& rStr, + sal_Int32 nIndex, sal_Int32 nLen ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetPoint() const { return maPt; } + const OUString& GetText() const { return maStr; } + sal_uInt32 GetWidth() const { return mnWidth; } + sal_Int32 GetIndex() const { return mnIndex; } + sal_Int32 GetLen() const { return mnLen; } +}; + +class SAL_DLLPUBLIC_RTTI MetaTextRectAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + OUString maStr; + DrawTextFlags mnStyle; + +public: + MetaTextRectAction(); + MetaTextRectAction(MetaTextRectAction const &) = default; + MetaTextRectAction(MetaTextRectAction &&) = default; + MetaTextRectAction & operator =(MetaTextRectAction const &) = delete; // due to MetaAction + MetaTextRectAction & operator =(MetaTextRectAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextRectAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTextRectAction( const tools::Rectangle& rRect, + const OUString& rStr, DrawTextFlags nStyle ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const OUString& GetText() const { return maStr; } + DrawTextFlags GetStyle() const { return mnStyle; } +}; + +class SAL_DLLPUBLIC_RTTI MetaTextLineAction final : public MetaAction +{ +private: + + Point maPos; + long mnWidth; + FontStrikeout meStrikeout; + FontLineStyle meUnderline; + FontLineStyle meOverline; + +public: + MetaTextLineAction(); + MetaTextLineAction(MetaTextLineAction const &) = default; + MetaTextLineAction(MetaTextLineAction &&) = default; + MetaTextLineAction & operator =(MetaTextLineAction const &) = delete; // due to MetaAction + MetaTextLineAction & operator =(MetaTextLineAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextLineAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTextLineAction( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontLineStyle eUnderline, + FontLineStyle eOverline ); + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Point& GetStartPoint() const { return maPos; } + long GetWidth() const { return mnWidth; } + FontStrikeout GetStrikeout() const { return meStrikeout; } + FontLineStyle GetUnderline() const { return meUnderline; } + FontLineStyle GetOverline() const { return meOverline; } +}; + +class VCL_DLLPUBLIC MetaBmpAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Point maPt; + +public: + MetaBmpAction(); + MetaBmpAction(MetaBmpAction const &) = default; + MetaBmpAction(MetaBmpAction &&) = default; + MetaBmpAction & operator =(MetaBmpAction const &) = delete; // due to MetaAction + MetaBmpAction & operator =(MetaBmpAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpAction( const Point& rPt, const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetPoint() const { return maPt; } +}; + +class VCL_DLLPUBLIC MetaBmpScaleAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Point maPt; + Size maSz; + +public: + MetaBmpScaleAction(); + MetaBmpScaleAction(MetaBmpScaleAction const &) = default; + MetaBmpScaleAction(MetaBmpScaleAction &&) = default; + MetaBmpScaleAction & operator =(MetaBmpScaleAction const &) = delete; // due to MetaAction + MetaBmpScaleAction & operator =(MetaBmpScaleAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpScaleAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpScaleAction( const Point& rPt, const Size& rSz, + const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaBmpScalePartAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + +public: + MetaBmpScalePartAction(); + MetaBmpScalePartAction(MetaBmpScalePartAction const &) = default; + MetaBmpScalePartAction(MetaBmpScalePartAction &&) = default; + MetaBmpScalePartAction & operator =(MetaBmpScalePartAction const &) = delete; // due to MetaAction + MetaBmpScalePartAction & operator =(MetaBmpScalePartAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpScalePartAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const Bitmap& rBmp ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } +}; + +class VCL_DLLPUBLIC MetaBmpExAction final : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maPt; + +public: + MetaBmpExAction(); + MetaBmpExAction(MetaBmpExAction const &) = default; + MetaBmpExAction(MetaBmpExAction &&) = default; + MetaBmpExAction & operator =(MetaBmpExAction const &) = delete; // due to MetaAction + MetaBmpExAction & operator =(MetaBmpExAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpExAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpExAction( const Point& rPt, const BitmapEx& rBmpEx ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetPoint() const { return maPt; } + bool IsTransparent() const override { return GetBitmapEx().IsTransparent(); } +}; + +class VCL_DLLPUBLIC MetaBmpExScaleAction final : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maPt; + Size maSz; + +public: + MetaBmpExScaleAction(); + MetaBmpExScaleAction(MetaBmpExScaleAction const &) = default; + MetaBmpExScaleAction(MetaBmpExScaleAction &&) = default; + MetaBmpExScaleAction & operator =(MetaBmpExScaleAction const &) = delete; // due to MetaAction + MetaBmpExScaleAction & operator =(MetaBmpExScaleAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpExScaleAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpExScaleAction( const Point& rPt, const Size& rSz, + const BitmapEx& rBmpEx ) ; + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } + bool IsTransparent() const override { return GetBitmapEx().IsTransparent(); } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaBmpExScalePartAction final : public MetaAction +{ +private: + + BitmapEx maBmpEx; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + +public: + MetaBmpExScalePartAction(); + MetaBmpExScalePartAction(MetaBmpExScalePartAction const &) = default; + MetaBmpExScalePartAction(MetaBmpExScalePartAction &&) = default; + MetaBmpExScalePartAction & operator =(MetaBmpExScalePartAction const &) = delete; // due to MetaAction + MetaBmpExScalePartAction & operator =(MetaBmpExScalePartAction &&) = delete; // due to MetaAction +private: + virtual ~MetaBmpExScalePartAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaBmpExScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const BitmapEx& rBmpEx ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const BitmapEx& GetBitmapEx() const { return maBmpEx; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } + bool IsTransparent() const override { return GetBitmapEx().IsTransparent(); } +}; + +class SAL_DLLPUBLIC_RTTI MetaMaskAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maPt; + +public: + MetaMaskAction(); + MetaMaskAction(MetaMaskAction const &) = default; + MetaMaskAction(MetaMaskAction &&) = default; + MetaMaskAction & operator =(MetaMaskAction const &) = delete; // due to MetaAction + MetaMaskAction & operator =(MetaMaskAction &&) = delete; // due to MetaAction +private: + virtual ~MetaMaskAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaMaskAction( const Point& rPt, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetPoint() const { return maPt; } +}; + +class SAL_DLLPUBLIC_RTTI MetaMaskScaleAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maPt; + Size maSz; + +public: + MetaMaskScaleAction(); + MetaMaskScaleAction(MetaMaskScaleAction const &) = default; + MetaMaskScaleAction(MetaMaskScaleAction &&) = default; + MetaMaskScaleAction & operator =(MetaMaskScaleAction const &) = delete; // due to MetaAction + MetaMaskScaleAction & operator =(MetaMaskScaleAction &&) = delete; // due to MetaAction +private: + virtual ~MetaMaskScaleAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaMaskScaleAction( const Point& rPt, const Size& rSz, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetPoint() const { return maPt; } + const Size& GetSize() const { return maSz; } +}; + +class SAL_DLLPUBLIC_RTTI MetaMaskScalePartAction final : public MetaAction +{ +private: + + Bitmap maBmp; + Color maColor; + Point maDstPt; + Size maDstSz; + Point maSrcPt; + Size maSrcSz; + +public: + MetaMaskScalePartAction(); + MetaMaskScalePartAction(MetaMaskScalePartAction const &) = default; + MetaMaskScalePartAction(MetaMaskScalePartAction &&) = default; + MetaMaskScalePartAction & operator =(MetaMaskScalePartAction const &) = delete; // due to MetaAction + MetaMaskScalePartAction & operator =(MetaMaskScalePartAction &&) = delete; // due to MetaAction +private: + virtual ~MetaMaskScalePartAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaMaskScalePartAction( const Point& rDstPt, const Size& rDstSz, + const Point& rSrcPt, const Size& rSrcSz, + const Bitmap& rBmp, + const Color& rColor ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const Bitmap& GetBitmap() const { return maBmp; } + const Color& GetColor() const { return maColor; } + const Point& GetDestPoint() const { return maDstPt; } + const Size& GetDestSize() const { return maDstSz; } + const Point& GetSrcPoint() const { return maSrcPt; } + const Size& GetSrcSize() const { return maSrcSz; } +}; + +class SAL_DLLPUBLIC_RTTI MetaGradientAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + Gradient maGradient; + +public: + MetaGradientAction(); + MetaGradientAction(MetaGradientAction const &) = default; + MetaGradientAction(MetaGradientAction &&) = default; + MetaGradientAction & operator =(MetaGradientAction const &) = delete; // due to MetaAction + MetaGradientAction & operator =(MetaGradientAction &&) = delete; // due to MetaAction +private: + virtual ~MetaGradientAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaGradientAction( const tools::Rectangle& rRect, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const Gradient& GetGradient() const { return maGradient; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaGradientExAction final : public MetaAction +{ +private: + + tools::PolyPolygon maPolyPoly; + Gradient maGradient; + +public: + MetaGradientExAction(); + MetaGradientExAction(MetaGradientExAction const &) = default; + MetaGradientExAction(MetaGradientExAction &&) = default; + MetaGradientExAction & operator =(MetaGradientExAction const &) = delete; // due to MetaAction + MetaGradientExAction & operator =(MetaGradientExAction &&) = delete; // due to MetaAction +private: + virtual ~MetaGradientExAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaGradientExAction( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + const Gradient& GetGradient() const { return maGradient; } +}; + +class SAL_DLLPUBLIC_RTTI MetaHatchAction final : public MetaAction +{ +private: + + tools::PolyPolygon maPolyPoly; + Hatch maHatch; + +public: + MetaHatchAction(); + MetaHatchAction(MetaHatchAction const &) = default; + MetaHatchAction(MetaHatchAction &&) = default; + MetaHatchAction & operator =(MetaHatchAction const &) = delete; // due to MetaAction + MetaHatchAction & operator =(MetaHatchAction &&) = delete; // due to MetaAction +private: + virtual ~MetaHatchAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaHatchAction( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + const Hatch& GetHatch() const { return maHatch; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaWallpaperAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + Wallpaper maWallpaper; + +public: + MetaWallpaperAction(); + MetaWallpaperAction(MetaWallpaperAction const &) = default; + MetaWallpaperAction(MetaWallpaperAction &&) = default; + MetaWallpaperAction & operator =(MetaWallpaperAction const &) = delete; // due to MetaAction + MetaWallpaperAction & operator =(MetaWallpaperAction &&) = delete; // due to MetaAction +private: + virtual ~MetaWallpaperAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaWallpaperAction( const tools::Rectangle& rRect, + const Wallpaper& rPaper ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } + const Wallpaper& GetWallpaper() const { return maWallpaper; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaClipRegionAction final : public MetaAction +{ +private: + + vcl::Region maRegion; + bool mbClip; + +public: + MetaClipRegionAction(); + MetaClipRegionAction(MetaClipRegionAction const &) = default; + MetaClipRegionAction(MetaClipRegionAction &&) = default; + MetaClipRegionAction & operator =(MetaClipRegionAction const &) = delete; // due to MetaAction + MetaClipRegionAction & operator =(MetaClipRegionAction &&) = delete; // due to MetaAction +private: + virtual ~MetaClipRegionAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaClipRegionAction( const vcl::Region& rRegion, bool bClip ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const vcl::Region& GetRegion() const { return maRegion; } + bool IsClipping() const { return mbClip; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaISectRectClipRegionAction final : public MetaAction +{ +private: + + tools::Rectangle maRect; + +public: + MetaISectRectClipRegionAction(); + MetaISectRectClipRegionAction(MetaISectRectClipRegionAction const &) = default; + MetaISectRectClipRegionAction(MetaISectRectClipRegionAction &&) = default; + MetaISectRectClipRegionAction & operator =(MetaISectRectClipRegionAction const &) = delete; // due to MetaAction + MetaISectRectClipRegionAction & operator =(MetaISectRectClipRegionAction &&) = delete; // due to MetaAction +private: + virtual ~MetaISectRectClipRegionAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaISectRectClipRegionAction( const tools::Rectangle& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::Rectangle& GetRect() const { return maRect; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaISectRegionClipRegionAction final : public MetaAction +{ +private: + + vcl::Region maRegion; + +public: + MetaISectRegionClipRegionAction(); + MetaISectRegionClipRegionAction(MetaISectRegionClipRegionAction const &) = default; + MetaISectRegionClipRegionAction(MetaISectRegionClipRegionAction &&) = default; + MetaISectRegionClipRegionAction & operator =(MetaISectRegionClipRegionAction const &) = delete; // due to MetaAction + MetaISectRegionClipRegionAction & operator =(MetaISectRegionClipRegionAction &&) = delete; // due to MetaAction +private: + virtual ~MetaISectRegionClipRegionAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaISectRegionClipRegionAction( const vcl::Region& ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const vcl::Region& GetRegion() const { return maRegion; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaMoveClipRegionAction final : public MetaAction +{ +private: + + long mnHorzMove; + long mnVertMove; + +public: + MetaMoveClipRegionAction(); + MetaMoveClipRegionAction(MetaMoveClipRegionAction const &) = default; + MetaMoveClipRegionAction(MetaMoveClipRegionAction &&) = default; + MetaMoveClipRegionAction & operator =(MetaMoveClipRegionAction const &) = delete; // due to MetaAction + MetaMoveClipRegionAction & operator =(MetaMoveClipRegionAction &&) = delete; // due to MetaAction +private: + virtual ~MetaMoveClipRegionAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaMoveClipRegionAction( long nHorzMove, long nVertMove ); + + virtual void Scale( double fScaleX, double fScaleY ) override; + + long GetHorzMove() const { return mnHorzMove; } + long GetVertMove() const { return mnVertMove; } +}; + +class VCL_DLLPUBLIC MetaLineColorAction final : public MetaAction +{ +private: + + Color maColor; + bool mbSet; + +public: + MetaLineColorAction(); + MetaLineColorAction(MetaLineColorAction const &) = default; + MetaLineColorAction(MetaLineColorAction &&) = default; + MetaLineColorAction & operator =(MetaLineColorAction const &) = delete; // due to MetaAction + MetaLineColorAction & operator =(MetaLineColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaLineColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaLineColorAction( const Color& rColor, bool bSet ); + + const Color& GetColor() const { return maColor; } + bool IsSetting() const { return mbSet; } +}; + +class VCL_DLLPUBLIC MetaFillColorAction final : public MetaAction +{ +private: + + Color maColor; + bool mbSet; + +public: + MetaFillColorAction(); + MetaFillColorAction(MetaFillColorAction const &) = default; + MetaFillColorAction(MetaFillColorAction &&) = default; + MetaFillColorAction & operator =(MetaFillColorAction const &) = delete; // due to MetaAction + MetaFillColorAction & operator =(MetaFillColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaFillColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaFillColorAction( const Color& rColor, bool bSet ); + + const Color& GetColor() const { return maColor; } + bool IsSetting() const { return mbSet; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextColorAction final : public MetaAction +{ +private: + + Color maColor; + +public: + MetaTextColorAction(); + MetaTextColorAction(MetaTextColorAction const &) = default; + MetaTextColorAction(MetaTextColorAction &&) = default; + MetaTextColorAction & operator =(MetaTextColorAction const &) = delete; // due to MetaAction + MetaTextColorAction & operator =(MetaTextColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaTextColorAction( const Color& ); + + const Color& GetColor() const { return maColor; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextFillColorAction final : public MetaAction +{ +private: + + Color maColor; + bool mbSet; + +public: + MetaTextFillColorAction(); + MetaTextFillColorAction(MetaTextFillColorAction const &) = default; + MetaTextFillColorAction(MetaTextFillColorAction &&) = default; + MetaTextFillColorAction & operator =(MetaTextFillColorAction const &) = delete; // due to MetaAction + MetaTextFillColorAction & operator =(MetaTextFillColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextFillColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTextFillColorAction( const Color& rColor, bool bSet ); + + const Color& GetColor() const { return maColor; } + bool IsSetting() const { return mbSet; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextLineColorAction final : public MetaAction +{ +private: + + Color maColor; + bool mbSet; + +public: + MetaTextLineColorAction(); + MetaTextLineColorAction(MetaTextLineColorAction const &) = default; + MetaTextLineColorAction(MetaTextLineColorAction &&) = default; + MetaTextLineColorAction & operator =(MetaTextLineColorAction const &) = delete; // due to MetaAction + MetaTextLineColorAction & operator =(MetaTextLineColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextLineColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTextLineColorAction( const Color& rColor, bool bSet ); + + const Color& GetColor() const { return maColor; } + bool IsSetting() const { return mbSet; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaOverlineColorAction final : public MetaAction +{ +private: + + Color maColor; + bool mbSet; + +public: + MetaOverlineColorAction(); + MetaOverlineColorAction(MetaOverlineColorAction const &) = default; + MetaOverlineColorAction(MetaOverlineColorAction &&) = default; + MetaOverlineColorAction & operator =(MetaOverlineColorAction const &) = delete; // due to MetaAction + MetaOverlineColorAction & operator =(MetaOverlineColorAction &&) = delete; // due to MetaAction +private: + virtual ~MetaOverlineColorAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaOverlineColorAction( const Color& rColor, bool bSet ); + + const Color& GetColor() const { return maColor; } + bool IsSetting() const { return mbSet; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextAlignAction final : public MetaAction +{ +private: + + TextAlign maAlign; + +public: + MetaTextAlignAction(); + MetaTextAlignAction(MetaTextAlignAction const &) = default; + MetaTextAlignAction(MetaTextAlignAction &&) = default; + MetaTextAlignAction & operator =(MetaTextAlignAction const &) = delete; // due to MetaAction + MetaTextAlignAction & operator =(MetaTextAlignAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextAlignAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaTextAlignAction( TextAlign eAlign ); + + TextAlign GetTextAlign() const { return maAlign; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaMapModeAction final : public MetaAction +{ +private: + + MapMode maMapMode; + +public: + MetaMapModeAction(); + MetaMapModeAction(MetaMapModeAction const &) = default; + MetaMapModeAction(MetaMapModeAction &&) = default; + MetaMapModeAction & operator =(MetaMapModeAction const &) = delete; // due to MetaAction + MetaMapModeAction & operator =(MetaMapModeAction &&) = delete; // due to MetaAction +private: + virtual ~MetaMapModeAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaMapModeAction( const MapMode& ); + + virtual void Scale( double fScaleX, double fScaleY ) override; + + const MapMode& GetMapMode() const { return maMapMode; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaFontAction final : public MetaAction +{ +private: + + vcl::Font maFont; + +public: + MetaFontAction(); + MetaFontAction(MetaFontAction const &) = default; + MetaFontAction(MetaFontAction &&) = default; + MetaFontAction & operator =(MetaFontAction const &) = delete; // due to MetaAction + MetaFontAction & operator =(MetaFontAction &&) = delete; // due to MetaAction +private: + virtual ~MetaFontAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaFontAction( const vcl::Font& ); + + virtual void Scale( double fScaleX, double fScaleY ) override; + + const vcl::Font& GetFont() const { return maFont; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPushAction final : public MetaAction +{ +private: + + PushFlags mnFlags; + +public: + MetaPushAction(); + MetaPushAction(MetaPushAction const &) = default; + MetaPushAction(MetaPushAction &&) = default; + MetaPushAction & operator =(MetaPushAction const &) = delete; // due to MetaAction + MetaPushAction & operator =(MetaPushAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPushAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaPushAction( PushFlags nFlags ); + + PushFlags GetFlags() const { return mnFlags; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaPopAction final : public MetaAction +{ +public: + + MetaPopAction(); + MetaPopAction(MetaPopAction const &) = default; + MetaPopAction(MetaPopAction &&) = default; + MetaPopAction & operator =(MetaPopAction const &) = delete; // due to MetaAction + MetaPopAction & operator =(MetaPopAction &&) = delete; // due to MetaAction +private: + virtual ~MetaPopAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaRasterOpAction final : public MetaAction +{ +private: + + RasterOp meRasterOp; + +public: + MetaRasterOpAction(); + MetaRasterOpAction(MetaRasterOpAction const &) = default; + MetaRasterOpAction(MetaRasterOpAction &&) = default; + MetaRasterOpAction & operator =(MetaRasterOpAction const &) = delete; // due to MetaAction + MetaRasterOpAction & operator =(MetaRasterOpAction &&) = delete; // due to MetaAction +private: + virtual ~MetaRasterOpAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaRasterOpAction( RasterOp eRasterOp ); + + RasterOp GetRasterOp() const { return meRasterOp; } +}; + +class SAL_DLLPUBLIC_RTTI MetaTransparentAction final : public MetaAction +{ +private: + + tools::PolyPolygon maPolyPoly; + sal_uInt16 mnTransPercent; + +public: + MetaTransparentAction(); + MetaTransparentAction(MetaTransparentAction const &) = default; + MetaTransparentAction(MetaTransparentAction &&) = default; + MetaTransparentAction & operator =(MetaTransparentAction const &) = delete; // due to MetaAction + MetaTransparentAction & operator =(MetaTransparentAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTransparentAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaTransparentAction( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransPercent ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const tools::PolyPolygon& GetPolyPolygon() const { return maPolyPoly; } + sal_uInt16 GetTransparence() const { return mnTransPercent; } + + bool IsTransparent() const override { return true; } +}; + +class SAL_DLLPUBLIC_RTTI MetaFloatTransparentAction final : public MetaAction +{ +private: + + GDIMetaFile maMtf; + Point maPoint; + Size maSize; + Gradient maGradient; + +public: + MetaFloatTransparentAction(); + MetaFloatTransparentAction(MetaFloatTransparentAction const &) = default; + MetaFloatTransparentAction(MetaFloatTransparentAction &&) = default; + MetaFloatTransparentAction & operator =(MetaFloatTransparentAction const &) = delete; // due to MetaAction + MetaFloatTransparentAction & operator =(MetaFloatTransparentAction &&) = delete; // due to MetaAction +private: + virtual ~MetaFloatTransparentAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaFloatTransparentAction( const GDIMetaFile& rMtf, const Point& rPos, + const Size& rSize, const Gradient& rGradient ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const GDIMetaFile& GetGDIMetaFile() const { return maMtf; } + const Point& GetPoint() const { return maPoint; } + const Size& GetSize() const { return maSize; } + const Gradient& GetGradient() const { return maGradient; } + bool IsTransparent() const override { return true; } +}; + +class VCL_DLLPUBLIC MetaEPSAction final : public MetaAction +{ +private: + + GfxLink maGfxLink; + GDIMetaFile maSubst; + Point maPoint; + Size maSize; + +public: + MetaEPSAction(); + MetaEPSAction(MetaEPSAction const &) = default; + MetaEPSAction(MetaEPSAction &&) = default; + MetaEPSAction & operator =(MetaEPSAction const &) = delete; // due to MetaAction + MetaEPSAction & operator =(MetaEPSAction &&) = delete; // due to MetaAction +private: + virtual ~MetaEPSAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaEPSAction( const Point& rPoint, const Size& rSize, + const GfxLink& rGfxLink, const GDIMetaFile& rSubst ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + const GfxLink& GetLink() const { return maGfxLink; } + const GDIMetaFile& GetSubstitute() const { return maSubst; } + const Point& GetPoint() const { return maPoint; } + const Size& GetSize() const { return maSize; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaRefPointAction final : public MetaAction +{ +private: + + Point maRefPoint; + bool mbSet; + +public: + MetaRefPointAction(); + MetaRefPointAction(MetaRefPointAction const &) = default; + MetaRefPointAction(MetaRefPointAction &&) = default; + MetaRefPointAction & operator =(MetaRefPointAction const &) = delete; // due to MetaAction + MetaRefPointAction & operator =(MetaRefPointAction &&) = delete; // due to MetaAction +private: + virtual ~MetaRefPointAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + MetaRefPointAction( const Point& rRefPoint, bool bSet ); + + const Point& GetRefPoint() const { return maRefPoint; } + bool IsSetting() const { return mbSet; } +}; + +class VCL_DLLPUBLIC MetaCommentAction final : public MetaAction +{ +private: + + OString maComment; + sal_Int32 mnValue; + sal_uInt32 mnDataSize; + std::unique_ptr<sal_uInt8[]> + mpData; + + SAL_DLLPRIVATE void ImplInitDynamicData( const sal_uInt8* pData, sal_uInt32 nDataSize ); + +private: + virtual ~MetaCommentAction() override; + +public: + explicit MetaCommentAction(); + explicit MetaCommentAction( const MetaCommentAction& rAct ); + explicit MetaCommentAction( const OString& rComment, sal_Int32 nValue = 0, const sal_uInt8* pData = nullptr, sal_uInt32 nDataSize = 0 ); + + virtual void Move( long nHorzMove, long nVertMove ) override; + virtual void Scale( double fScaleX, double fScaleY ) override; + + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + const OString& GetComment() const { return maComment; } + sal_Int32 GetValue() const { return mnValue; } + sal_uInt32 GetDataSize() const { return mnDataSize; } + const sal_uInt8* GetData() const { return mpData.get(); } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaLayoutModeAction final : public MetaAction +{ +private: + + ComplexTextLayoutFlags mnLayoutMode; + +public: + MetaLayoutModeAction(); + MetaLayoutModeAction(MetaLayoutModeAction const &) = default; + MetaLayoutModeAction(MetaLayoutModeAction &&) = default; + MetaLayoutModeAction & operator =(MetaLayoutModeAction const &) = delete; // due to MetaAction + MetaLayoutModeAction & operator =(MetaLayoutModeAction &&) = delete; // due to MetaAction +private: + virtual ~MetaLayoutModeAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaLayoutModeAction( ComplexTextLayoutFlags nLayoutMode ); + + ComplexTextLayoutFlags GetLayoutMode() const { return mnLayoutMode; } +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaTextLanguageAction final : public MetaAction +{ +private: + + LanguageType meTextLanguage; + +public: + MetaTextLanguageAction(); + MetaTextLanguageAction(MetaTextLanguageAction const &) = default; + MetaTextLanguageAction(MetaTextLanguageAction &&) = default; + MetaTextLanguageAction & operator =(MetaTextLanguageAction const &) = delete; // due to MetaAction + MetaTextLanguageAction & operator =(MetaTextLanguageAction &&) = delete; // due to MetaAction +private: + virtual ~MetaTextLanguageAction() override; +public: + virtual void Execute( OutputDevice* pOut ) override; + virtual rtl::Reference<MetaAction> Clone() override; + virtual void Write( SvStream& rOStm, ImplMetaWriteData* pData ) override; + virtual void Read( SvStream& rIStm, ImplMetaReadData* pData ) override; + + explicit MetaTextLanguageAction( LanguageType ); + + LanguageType GetTextLanguage() const { return meTextLanguage; } +}; + +#endif // INCLUDED_VCL_METAACT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/metaactiontypes.hxx b/include/vcl/metaactiontypes.hxx new file mode 100644 index 000000000..5a8a70cae --- /dev/null +++ b/include/vcl/metaactiontypes.hxx @@ -0,0 +1,85 @@ +/* -*- 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_METAACTIONTYPES_HXX +#define INCLUDED_VCL_METAACTIONTYPES_HXX + +enum class MetaActionType +{ + NONE = 0, + PIXEL = 100, + POINT = 101, + LINE = 102, + RECT = 103, + ROUNDRECT = 104, + ELLIPSE = 105, + ARC = 106, + PIE = 107, + CHORD = 108, + POLYLINE = 109, + POLYGON = 110, + POLYPOLYGON = 111, + TEXT = 112, + TEXTARRAY = 113, + STRETCHTEXT = 114, + TEXTRECT = 115, + BMP = 116, + BMPSCALE = 117, + BMPSCALEPART = 118, + BMPEX = 119, + BMPEXSCALE = 120, + BMPEXSCALEPART = 121, + MASK = 122, + MASKSCALE = 123, + MASKSCALEPART = 124, + GRADIENT = 125, + HATCH = 126, + WALLPAPER = 127, + CLIPREGION = 128, + ISECTRECTCLIPREGION = 129, + ISECTREGIONCLIPREGION = 130, + MOVECLIPREGION = 131, + LINECOLOR = 132, + FILLCOLOR = 133, + TEXTCOLOR = 134, + TEXTFILLCOLOR = 135, + TEXTALIGN = 136, + MAPMODE = 137, + FONT = 138, + PUSH = 139, + POP = 140, + RASTEROP = 141, + Transparent = 142, + EPS = 143, + REFPOINT = 144, + TEXTLINECOLOR = 145, + TEXTLINE = 146, + FLOATTRANSPARENT = 147, + GRADIENTEX = 148, + LAYOUTMODE = 149, + TEXTLANGUAGE = 150, + OVERLINECOLOR = 151, + + COMMENT = 512, + LAST = COMMENT +}; + +#endif // INCLUDED_VCL_METAACTIONTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx new file mode 100644 index 000000000..0eb584960 --- /dev/null +++ b/include/vcl/metric.hxx @@ -0,0 +1,97 @@ +/* -*- 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_METRIC_HXX +#define INCLUDED_VCL_METRIC_HXX + +#include <vcl/dllapi.h> +#include <vcl/font.hxx> +#include <tools/ref.hxx> +#include <tools/gen.hxx> + +class FontCharMap; + +typedef sal_uInt32 sal_UCS4; +typedef tools::SvRef<FontCharMap> FontCharMapRef; + +class VCL_DLLPUBLIC FontMetric : public vcl::Font +{ +public: + explicit FontMetric(); + FontMetric( const FontMetric& ); // TODO make this explicit + ~FontMetric() override; + + long GetAscent() const { return mnAscent; } + long GetDescent() const { return mnDescent; } + long GetInternalLeading() const { return mnIntLeading; } + long GetExternalLeading() const { return mnExtLeading; } + long GetLineHeight() const { return mnLineHeight; } // TODO this is ascent + descnt + long GetSlant() const { return mnSlant; } + long GetBulletOffset() const { return mnBulletOffset; } + + void SetAscent( long nAscent ) { mnAscent = nAscent; } + void SetDescent( long nDescent ) { mnDescent = nDescent; } + void SetExternalLeading( long nExtLeading ) { mnExtLeading = nExtLeading; } + void SetInternalLeading( long nIntLeading ) { mnIntLeading = nIntLeading; } + void SetLineHeight( long nHeight ) { mnLineHeight = nHeight; } // TODO this is ascent + descent + void SetSlant( long nSlant ) { mnSlant = nSlant; } + void SetBulletOffset( long nOffset ) { mnBulletOffset = nOffset; } + + bool IsFullstopCentered() const { return mbFullstopCentered; } + + void SetFullstopCenteredFlag( bool bCentered ) { mbFullstopCentered = bCentered; } + + using Font::operator=; + FontMetric& operator=( const FontMetric& rMetric ); + FontMetric& operator=( FontMetric&& rMetric ); + bool operator==( const FontMetric& rMetric ) const; + bool operator!=( const FontMetric& rMetric ) const + { return !operator==( rMetric ); } +private: + long mnAscent; // Ascent + long mnDescent; // Descent + long mnIntLeading; // Internal Leading + long mnExtLeading; // External Leading + long mnLineHeight; // Ascent+Descent+EmphasisMark + long mnSlant; // Slant + long mnBulletOffset; // Offset for non-printing character + + bool mbFullstopCentered; +}; + +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const FontMetric& rMetric ) +{ + stream << "{" + << "name=" << "\"" << rMetric.GetFamilyName() << "\"" + << ",size=(" << rMetric.GetFontSize().Width() << "," << rMetric.GetFontSize().Height() << ")" + << ",ascent=" << rMetric.GetAscent() + << ",descent=" << rMetric.GetDescent() + << ",intLeading=" << rMetric.GetInternalLeading() + << ",extLeading=" << rMetric.GetExternalLeading() + << ",lineHeight=" << rMetric.GetLineHeight() + << ",slant=" << rMetric.GetSlant() + << "}"; + return stream; +} + +#endif // INCLUDED_VCL_METRIC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/mnemonic.hxx b/include/vcl/mnemonic.hxx new file mode 100644 index 000000000..9d144c24f --- /dev/null +++ b/include/vcl/mnemonic.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_MNEMONIC_HXX +#define INCLUDED_VCL_MNEMONIC_HXX + +#include <com/sun/star/uno/Reference.h> +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> + +namespace com::sun::star::i18n { class XCharacterClassification; } + +// Mnemonic Chars, which we want support +// Latin 0-9 +#define MNEMONIC_RANGE_1_START 0x30 +#define MNEMONIC_RANGE_1_END 0x39 +// Latin A-Z +#define MNEMONIC_RANGE_2_START 0x61 +#define MNEMONIC_RANGE_2_END 0x7A +// Cyrillic +#define MNEMONIC_RANGE_3_START 0x0430 +#define MNEMONIC_RANGE_3_END 0x044F +// Greek +#define MNEMONIC_RANGE_4_START 0x03B1 +#define MNEMONIC_RANGE_4_END 0x03CB +#define MNEMONIC_RANGES 4 +#define MAX_MNEMONICS ((MNEMONIC_RANGE_1_END-MNEMONIC_RANGE_1_START+1)+\ + (MNEMONIC_RANGE_2_END-MNEMONIC_RANGE_2_START+1)+\ + (MNEMONIC_RANGE_3_END-MNEMONIC_RANGE_3_START+1)+\ + (MNEMONIC_RANGE_4_END-MNEMONIC_RANGE_4_START+1)) + +#define MNEMONIC_CHAR u'~' +#define MNEMONIC_INDEX_NOTFOUND (sal_uInt16(0xFFFF)) + + +class VCL_DLLPUBLIC MnemonicGenerator +{ + sal_Unicode m_cMnemonic; + // 0 == Mnemonic; >0 == count of characters + sal_uInt8 maMnemonics[MAX_MNEMONICS]; + css::uno::Reference< css::i18n::XCharacterClassification > mxCharClass; + + SAL_DLLPRIVATE static sal_uInt16 ImplGetMnemonicIndex( sal_Unicode c ); + SAL_DLLPRIVATE sal_Unicode ImplFindMnemonic( const OUString& rKey ); + +public: + MnemonicGenerator(sal_Unicode cMnemonic = MNEMONIC_CHAR); + + void RegisterMnemonic( const OUString& rKey ); + OUString CreateMnemonic( const OUString& rKey ); + css::uno::Reference< css::i18n::XCharacterClassification > const & GetCharClass(); + + // returns a string where all '~'-characters and CJK mnemonics of the form (~A) are completely removed + static OUString EraseAllMnemonicChars( const OUString& rStr ); +}; + +#endif // INCLUDED_VCL_MNEMONIC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/mnemonicengine.hxx b/include/vcl/mnemonicengine.hxx new file mode 100644 index 000000000..45d05b5d0 --- /dev/null +++ b/include/vcl/mnemonicengine.hxx @@ -0,0 +1,153 @@ +/* -*- 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_MNEMONICENGINE_HXX +#define INCLUDED_VCL_MNEMONICENGINE_HXX + +#include <vcl/dllapi.h> + +#include <sal/config.h> +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#include <memory> + +class KeyEvent; + + +namespace vcl +{ + + + //= IMnemonicEntryList + + /// callback for a MnemonicEngine + class SAL_NO_VTABLE VCL_DLLPUBLIC IMnemonicEntryList + { + public: + /** returns the first list entry for the mnemonic search + + @return + a pointer which can be used to unuquely identify the entry. + The MenomonicEngine itself does not use this value, it + is only passed to other methods of this callback interface. + + If this value is NULL, searching stops. + */ + virtual const void* FirstSearchEntry( OUString& _rEntryText ) const = 0; + + /** returns the next list entry for the mnemonic search + + @return + a pointer which can be used to unuquely identify the entry. + The MenomonicEngine itself does not use this value, it + is only passed to other methods of this callback interface. + + If this value is NULL, searching stops. + + If this value is the same as returned by the previous call + to FirstSearchEntry (i.e. you cycled + around), then searching stops, too. + */ + virtual const void* NextSearchEntry( const void* _pCurrentSearchEntry, OUString& _rEntryText ) const = 0; + + /** "selects" a given entry. + + Note: The semantics of "select" depends on your implementation. You + might actually really select the entry (in the sense of a selected + list box entry, for example), you might make it the current entry, + if your implementation supports this - whatever. + + @param _pEntry + the entry to select. This is the return value of a previous call + to FirstSearchEntry or NextSearchEntry. + */ + virtual void SelectSearchEntry( const void* _pEntry ) = 0; + + /** "executes" the current search entry, i.e. the one returned + in the previous NextSearchEntry call. + + Note: The semantics of "execute" depends on your implementation. You + might even have a list of entries which cannot be executed at all. + + This method is called after SelectSearchEntry, + if and only if the current entry's mnemonic is unambiguous. + + For instance, imagine a list which has two entries with the same mnemonic + character, say "c". Now if the user presses <code>Alt-C</code>, the MnemonicEngine + will call SelectCurrentEntry as soon as it encounters + the first entry, but it'll never call ExecuteSearchEntry. + + If, however, "c" is a unique mnemonic character in your entry list, then the + call of SelectSearchEntry will be followed by a + call to ExecuteSearchEntry. + + This way, you can implement cyclic selection of entries: In + FirstSearchEntry, return the entry which was previously + selected, and in NextSearchEntry, internally cycle around + in your list. Then, multiple user inputs of <code>Alt-C</code> will + cycle through all entries with the mnemonic being "c". + + @param _pEntry + the entry to select. This is the return value of a previous call + to FirstSearchEntry or NextSearchEntry. + */ + virtual void ExecuteSearchEntry( const void* _pEntry ) const = 0; + + protected: + ~IMnemonicEntryList() {} + }; + + + //= MnemonicEngine + + struct MnemonicEngine_Data; + class MnemonicEngine + { + ::std::unique_ptr< MnemonicEngine_Data > m_pData; + + public: + MnemonicEngine( IMnemonicEntryList& _rEntryList ); + ~MnemonicEngine(); + + /** handles a key event + + If the key event denotes pressing an accelerator key, then the + entry list is searched for a matching entry. If such an entry is + found, IMnemonicEntryList::SelectSearchEntry + is called. + + If the entry is the only one with the given mnemonic character, then + also IMnemonicEntryList::ExecuteSearchEntry + is called. + + @return + if the key event has been handled, and should thus not be processed + further. + */ + bool HandleKeyEvent( const KeyEvent& _rKEvt ); + }; + + +} // namespace vcl + + +#endif // INCLUDED_VCL_MNEMONICENGINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/mtfxmldump.hxx b/include/vcl/mtfxmldump.hxx new file mode 100644 index 000000000..3bdf4d663 --- /dev/null +++ b/include/vcl/mtfxmldump.hxx @@ -0,0 +1,44 @@ +/* -*- 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_MTFXMLDUMP_HXX +#define INCLUDED_VCL_MTFXMLDUMP_HXX + +#include <sal/config.h> +#include <vcl/dllapi.h> +#include <vcl/metaactiontypes.hxx> +#include <o3tl/enumarray.hxx> + +namespace tools { class XmlWriter; } +class GDIMetaFile; +class SvStream; + +enum class MetaActionType; + +class VCL_DLLPUBLIC MetafileXmlDump final +{ + o3tl::enumarray<MetaActionType, bool> maFilter; + + void writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& rWriter); + +public: + MetafileXmlDump(); + ~MetafileXmlDump(); + + void filterActionType(const MetaActionType nActionType, bool bShouldFilter); + void filterAllActionTypes(); + + /** The actual result that will be used for testing. + */ + void dump(const GDIMetaFile& rMetaFile, SvStream& rStream); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/naturalsort.hxx b/include/vcl/naturalsort.hxx new file mode 100644 index 000000000..852c8472b --- /dev/null +++ b/include/vcl/naturalsort.hxx @@ -0,0 +1,19 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <vcl/dllapi.h> + +namespace vcl +{ +VCL_DLLPUBLIC sal_Int32 NaturalSortCompare(const OUString& rA, const OUString& rB); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/notebookbar.hxx b/include/vcl/notebookbar.hxx new file mode 100644 index 000000000..bfa75d680 --- /dev/null +++ b/include/vcl/notebookbar.hxx @@ -0,0 +1,68 @@ +/* -*- 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_NOTEBOOKBAR_HXX +#define INCLUDED_VCL_NOTEBOOKBAR_HXX + +#include <vcl/builder.hxx> +#include <vcl/ctrl.hxx> +#include <vcl/NotebookBarAddonsMerger.hxx> +#include <vcl/settings.hxx> +#include <set> +#include <vector> + +namespace com::sun::star::ui { class XContextChangeEventListener; } + +class NotebookbarContextControl; +class SystemWindow; + +/// This implements Widget Layout-based notebook-like menu bar. +class VCL_DLLPUBLIC NotebookBar final : public Control, public VclBuilderContainer +{ +friend class NotebookBarContextChangeEventListener; +public: + NotebookBar(Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame>& rFrame, + const NotebookBarAddonsItem& aNotebookBarAddonsItem); + virtual ~NotebookBar() override; + virtual void dispose() override; + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual Size GetOptimalSize() const override; + virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All) override; + virtual void Resize() override; + + void SetSystemWindow(SystemWindow* pSystemWindow); + + void StateChanged(const StateChangedType nStateChange ) override; + + void DataChanged(const DataChangedEvent& rDCEvt) override; + + void ControlListenerForCurrentController(bool bListen); + void StopListeningAllControllers(); + +private: + VclPtr<SystemWindow> m_pSystemWindow; + css::uno::Reference<css::ui::XContextChangeEventListener> m_pEventListener; + std::set<css::uno::Reference<css::frame::XController>> m_alisteningControllers; + std::vector<NotebookbarContextControl*> m_pContextContainers; + css::uno::Reference<css::frame::XFrame> mxFrame; + + AllSettings DefaultSettings; + AllSettings PersonaSettings; + + void UpdateBackground(); + + void UpdateDefaultSettings(); + void UpdatePersonaSettings(); +}; + +#endif // INCLUDED_VCL_NOTEBOOKBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx new file mode 100644 index 000000000..3b74b0d76 --- /dev/null +++ b/include/vcl/oldprintadaptor.hxx @@ -0,0 +1,53 @@ +/* -*- 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_OLDPRINTADAPTOR_HXX +#define INCLUDED_VCL_OLDPRINTADAPTOR_HXX + +#include <config_options.h> +#include <memory> +#include <vcl/print.hxx> + +namespace weld +{ + class Window; +} + +namespace vcl +{ + struct ImplOldStyleAdaptorData; + class UNLESS_MERGELIBS(VCL_DLLPUBLIC) OldStylePrintAdaptor final : public PrinterController + { + std::unique_ptr<ImplOldStyleAdaptorData> mpData; + public: + OldStylePrintAdaptor(const VclPtr<Printer>&, weld::Window*); + virtual ~OldStylePrintAdaptor() override; + + void StartPage(); + void EndPage(); + + virtual int getPageCount() const override; + virtual css::uno::Sequence< css::beans::PropertyValue > getPageParameters( int i_nPage ) const override; + virtual void printPage( int i_nPage ) const override; + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx new file mode 100644 index 000000000..c6807a6fe --- /dev/null +++ b/include/vcl/opengl/OpenGLContext.hxx @@ -0,0 +1,188 @@ +/* -*- 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_OPENGL_OPENGLCONTEXT_HXX +#define INCLUDED_VCL_OPENGL_OPENGLCONTEXT_HXX + +#include <epoxy/gl.h> + +#include <vcl/dllapi.h> +#include <vcl/syschild.hxx> +#include <rtl/ref.hxx> + +#include <memory> +#include <unordered_map> + +class OpenGLFramebuffer; +class OpenGLProgram; +class OpenGLTexture; +class RenderState; + +/// Holds the information of our new child window +struct VCL_DLLPUBLIC GLWindow +{ + unsigned int Width; + unsigned int Height; + bool bMultiSampleSupported; + + GLWindow() + : Width(0) + , Height(0) + , bMultiSampleSupported(false) + { + } + + virtual bool Synchronize(bool bOnoff) const; + + virtual ~GLWindow(); +}; + +struct VCL_DLLPUBLIC OpenGLCapabilitySwitch +{ + bool mbLimitedShaderRegisters; + + OpenGLCapabilitySwitch() + : mbLimitedShaderRegisters(false) + {} +}; + +class VCL_DLLPUBLIC OpenGLContext +{ + friend class OpenGLTests; +protected: + OpenGLContext(); +public: + static rtl::Reference<OpenGLContext> Create(); + virtual ~OpenGLContext(); + void acquire() { mnRefCount++; } + void release() { if ( --mnRefCount == 0 ) delete this; } + void dispose(); + + void requestLegacyContext(); + + bool init(vcl::Window* pParent); + + void reset(); + + // use these methods right after setting a context to make sure drawing happens + // in the right FBO (default one is for onscreen painting) + void BindFramebuffer( OpenGLFramebuffer* pFramebuffer ); + void AcquireDefaultFramebuffer(); + OpenGLFramebuffer* AcquireFramebuffer( const OpenGLTexture& rTexture ); + static void ReleaseFramebuffer( OpenGLFramebuffer* pFramebuffer ); + void UnbindTextureFromFramebuffers( GLuint nTexture ); + static bool IsTextureAttachedAnywhere( GLuint nTexture ); + + void ReleaseFramebuffer( const OpenGLTexture& rTexture ); + void ReleaseFramebuffers(); + + // retrieve a program from the cache or compile/link it + OpenGLProgram* GetProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" ); + OpenGLProgram* UseProgram( const OUString& rVertexShader, const OUString& rFragmentShader, const OString& preamble = "" ); + + RenderState& state() + { + return *mpRenderState; + } + + OpenGLCapabilitySwitch& getOpenGLCapabilitySwitch() + { + return maOpenGLCapabilitySwitch; + } + + /// Is this GL context the current context ? + virtual bool isCurrent(); + /// Is any GL context the current context ? + virtual bool isAnyCurrent(); + /// release bound resources from the current context + static void clearCurrent(); + /// release contexts etc. before (potentially) allowing another thread run. + static void prepareForYield(); + /// Is there a current GL context ? + static bool hasCurrent(); + + /// make a VCL context (any context) current, create it if necessary. + static void makeVCLCurrent(); + /// fetch any VCL context, creating one if bMakeIfNecessary is set. + static rtl::Reference<OpenGLContext> getVCLContext(bool bMakeIfNecessary = true); + /// make this GL context current - so it is implicit in subsequent GL calls + virtual void makeCurrent(); + /// Put this GL context to the end of the context list. + void registerAsCurrent(); + /// reset the GL context so this context is not implicit in subsequent GL calls. + virtual void resetCurrent(); + /// unbind the GL_FRAMEBUFFER to its default state, needed for gtk3 + virtual void restoreDefaultFramebuffer(); + virtual void swapBuffers(); + virtual void sync(); + void show(); + + void setWinPosAndSize(const Point &rPos, const Size& rSize); + virtual const GLWindow& getOpenGLWindow() const = 0; + + SystemChildWindow* getChildWindow(); + const SystemChildWindow* getChildWindow() const; + + bool isInitialized() const + { + return mbInitialized; + } + + /// VCL promiscuously re-uses its own contexts: + void setVCLOnly() { mbVCLOnly = true; } + bool isVCLOnly() const { return mbVCLOnly; } + + virtual SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext); + +private: + virtual void initWindow(); + virtual void destroyCurrentContext(); + virtual void adjustToNewSize(); + +protected: + bool InitGL(); + static void InitGLDebugging(); + static void InitChildWindow(SystemChildWindow *pChildWindow); + static void BuffersSwapped(); + virtual GLWindow& getModifiableOpenGLWindow() = 0; + virtual bool ImplInit(); + + VclPtr<vcl::Window> m_xWindow; + VclPtr<vcl::Window> mpWindow; //points to m_pWindow or the parent window, don't delete it + VclPtr<SystemChildWindow> m_pChildWindow; + bool mbInitialized; + int mnRefCount; + bool mbRequestLegacyContext; + bool mbVCLOnly; + + int mnFramebufferCount; + OpenGLFramebuffer* mpCurrentFramebuffer; + OpenGLFramebuffer* mpFirstFramebuffer; + OpenGLFramebuffer* mpLastFramebuffer; + + OpenGLCapabilitySwitch maOpenGLCapabilitySwitch; + +private: + typedef std::unordered_map< OString, std::shared_ptr<OpenGLProgram> > ProgramCollection; + ProgramCollection maPrograms; + OpenGLProgram* mpCurrentProgram; + + std::unique_ptr<RenderState> mpRenderState; + +public: + vcl::Region maClipRegion; + + // Don't hold references to ourselves: + OpenGLContext *mpPrevContext; + OpenGLContext *mpNextContext; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/opengl/OpenGLHelper.hxx b/include/vcl/opengl/OpenGLHelper.hxx new file mode 100644 index 000000000..4f365c2e4 --- /dev/null +++ b/include/vcl/opengl/OpenGLHelper.hxx @@ -0,0 +1,126 @@ +/* -*- 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_OPENGL_OPENGLHELPER_HXX +#define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX + +#include <epoxy/gl.h> +#include <sal/detail/log.h> +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> + +#include <rtl/ustring.hxx> +#include <sstream> + +/// Helper to do a SAL_INFO as well as a GL log. +#define VCL_GL_INFO(stream) \ + do { \ + if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \ + { \ + ::std::ostringstream detail_stream; \ + detail_stream << stream; \ + OpenGLHelper::debugMsgStream(detail_stream); \ + } \ + } while (false) + +/// Helper to do a SAL_WARN as well as a GL log. +#define VCL_GL_WARN(stream) \ + do { \ + if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \ + { \ + ::std::ostringstream detail_stream; \ + detail_stream << stream; \ + OpenGLHelper::debugMsgStreamWarn(detail_stream); \ + } \ + } while (false) + +// All member functions static and VCL_DLLPUBLIC. Basically a glorified namespace. +struct VCL_DLLPUBLIC OpenGLHelper +{ + OpenGLHelper() = delete; // Should not be instantiated + +public: + + static OString GetDigest(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble ); + + static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName, const OString& preamble, const OString& rDigest ); + static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble, const OString& rDigest ); + static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName); + static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName); + + /** + * The caller is responsible for allocating the memory for the buffer before calling + * this method. The buffer size is assumed to be 4*width*height and the format + * to be OptimalBufferFormat(). + **/ + static BitmapEx ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight); + /** + * Returns the optimal buffer format for OpenGL (GL_BGRA or GL_RGBA). + **/ + static GLenum OptimalBufferFormat(); + static void renderToFile(long nWidth, long nHeight, const OUString& rFileName); + + static const char* GLErrorString(GLenum errorCode); + + /** + * The caller is responsible for deleting the buffer objects identified by + * nFramebufferId, nRenderbufferDepthId and nRenderbufferColorId. + * This create a buffer for rendering to texture and should be freed with + * glDeleteTextures. + * + * @param nWidth Width of frame + * @param nHeight Height of frame + * @param nFramebufferId FrameBuffer ID + * @param nRenderbufferDepthId RenderBuffer's depth ID + * @param nRenderbufferColorId RenderBuffer's color ID + */ + static void createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId, + GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId); + + /// Get OpenGL version (needs a context) + static float getGLVersion(); + + static void checkGLError(const char* aFile, size_t nLine); + + /** + * Insert a glDebugMessage into the queue - helpful for debugging + * with apitrace to annotate the output and correlate it with code. + */ +#if defined __GNUC__ + __attribute__ ((format (printf, 2, 3))) +#endif + static void debugMsgPrint(const int nType, const char *pFormat, ...); + static void debugMsgStream(std::ostringstream const &pStream); + static void debugMsgStreamWarn(std::ostringstream const &pStream); + + /** + * checks if the device/driver pair is on our OpenGL blacklist + */ + static bool isDeviceBlacklisted(); + + /** + * checks if the system supports all features that are necessary for the OpenGL VCL support + */ + static bool supportsVCLOpenGL(); + + /** + * Returns true if VCL has OpenGL rendering enabled + */ + static bool isVCLOpenGLEnabled(); +}; + +#ifdef SAL_LOG_WARN +#define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__) +#else +#define CHECK_GL_ERROR() do { } while (false) +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/opengl/OpenGLWrapper.hxx b/include/vcl/opengl/OpenGLWrapper.hxx new file mode 100644 index 000000000..c84286ea5 --- /dev/null +++ b/include/vcl/opengl/OpenGLWrapper.hxx @@ -0,0 +1,41 @@ +/* -*- 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/. + */ + +// Fully wrapped methods that have no exotic GL header deps. + +#ifndef INCLUDED_VCL_OPENGL_OPENGLWRAPPER_HXX +#define INCLUDED_VCL_OPENGL_OPENGLWRAPPER_HXX + +#include <config_features.h> +#include <vcl/dllapi.h> + +// All member functions static and VCL_DLLPUBLIC. Basically a glorified namespace. +struct VCL_DLLPUBLIC OpenGLWrapper +{ + OpenGLWrapper() = delete; // Should not be instantiated + + /** + * Returns true if VCL has OpenGL rendering enabled + */ +#if HAVE_FEATURE_UI + static bool isVCLOpenGLEnabled(); + + /** + * Returns the number of times OpenGL buffers have been swapped. + */ + static sal_Int64 getBufferSwapCounter(); +#else + static bool isVCLOpenGLEnabled() + { + return false; + } +#endif +}; + +#endif // INCLUDED_VCL_OPENGL_OPENGLWRAPPER_HXX diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx new file mode 100644 index 000000000..42b2d4cdf --- /dev/null +++ b/include/vcl/outdev.hxx @@ -0,0 +1,2021 @@ +/* -*- 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_OUTDEV_HXX +#define INCLUDED_VCL_OUTDEV_HXX + +#include <tools/gen.hxx> +#include <tools/ref.hxx> +#include <tools/solar.h> +#include <tools/color.hxx> +#include <tools/poly.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <vcl/bitmap.hxx> +#include <vcl/cairo.hxx> +#include <vcl/devicecoordinate.hxx> +#include <vcl/dllapi.h> +#include <vcl/font.hxx> +#include <vcl/region.hxx> +#include <vcl/mapmod.hxx> +#include <vcl/wall.hxx> +#include <vcl/metaactiontypes.hxx> +#include <vcl/salnativewidgets.hxx> +#include <vcl/outdevstate.hxx> +#include <vcl/outdevmap.hxx> +#include <vcl/vclreferencebase.hxx> + +#include <basegfx/numeric/ftools.hxx> +#include <basegfx/vector/b2enums.hxx> +#include <basegfx/polygon/b2dpolypolygon.hxx> + +#include <unotools/fontdefs.hxx> + +#include <com/sun/star/drawing/LineCap.hpp> +#include <com/sun/star/uno/Reference.h> + +#include <memory> +#include <vector> + +struct ImplOutDevData; +class LogicalFontInstance; +struct SystemGraphicsData; +struct SystemFontData; +struct SystemTextLayoutData; +class ImplFontCache; +class PhysicalFontCollection; +class ImplDeviceFontList; +class ImplDeviceFontSizeList; +class ImplMultiTextLineInfo; +class SalGraphics; +class Gradient; +class Hatch; +class AllSettings; +class BitmapReadAccess; +class BitmapEx; +class Image; +class TextRectInfo; +class FontMetric; +class GDIMetaFile; +class GfxLink; +namespace tools { + class Line; +} +class LineInfo; +class AlphaMask; +class FontCharMap; +class SalLayout; +class ImplLayoutArgs; +class VirtualDevice; +struct SalTwoRect; +class Printer; +class VCLXGraphics; +class OutDevStateStack; +class SalLayoutGlyphs; + +namespace vcl +{ + class ExtOutDevData; + class ITextLayout; + struct FontCapabilities; + class TextLayoutCache; + class Window; + namespace font { + struct Feature; + } +} + +namespace basegfx { + class B2DHomMatrix; + class B2DPolygon; + class B2IVector; + typedef B2IVector B2ISize; +} + +namespace com::sun::star::awt { + class XGraphics; +} + +#if defined UNX +#define GLYPH_FONT_HEIGHT 128 +#else +#define GLYPH_FONT_HEIGHT 256 +#endif + +// Text Layout options +enum class SalLayoutFlags +{ + NONE = 0x0000, + BiDiRtl = 0x0001, + BiDiStrong = 0x0002, + RightAlign = 0x0004, + DisableKerning = 0x0010, + KerningAsian = 0x0020, + Vertical = 0x0040, + KashidaJustification = 0x0800, + ForFallback = 0x2000, + GlyphItemsOnly = 0x4000, +}; +namespace o3tl +{ + template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x6877> {}; +} + +typedef std::vector< tools::Rectangle > MetricVector; + +// OutputDevice-Types + +// Flags for DrawText() +enum class DrawTextFlags +{ + NONE = 0x00000000, + Disable = 0x00000001, + Mnemonic = 0x00000002, + Mono = 0x00000004, + Clip = 0x00000008, + Left = 0x00000010, + Center = 0x00000020, + Right = 0x00000040, + Top = 0x00000080, + VCenter = 0x00000100, + Bottom = 0x00000200, + EndEllipsis = 0x00000400, + PathEllipsis = 0x00000800, + MultiLine = 0x00001000, + WordBreak = 0x00002000, + NewsEllipsis = 0x00004000, + WordBreakHyphenation = 0x00008000 | WordBreak, + CenterEllipsis = 0x00010000, + HideMnemonic = 0x00020000, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawTextFlags> : is_typed_flags<DrawTextFlags, 0x3ffff> {}; +} + +// Flags for DrawImage(), these must match the definitions in css::awt::ImageDrawMode +enum class DrawImageFlags +{ + NONE = 0x0000, + Disable = 0x0001, + Highlight = 0x0002, + Deactive = 0x0004, + ColorTransform = 0x0008, + SemiTransparent = 0x0010, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawImageFlags> : is_typed_flags<DrawImageFlags, 0x001f> {}; +} + +// Flags for DrawGrid() +enum class DrawGridFlags +{ + NONE = 0x0000, + Dots = 0x0001, + HorzLines = 0x0002, + VertLines = 0x0004 +}; +namespace o3tl +{ + template<> struct typed_flags<DrawGridFlags> : is_typed_flags<DrawGridFlags, 0x0007> {}; +} + +// DrawModes +enum class DrawModeFlags : sal_uInt32 +{ + Default = 0x00000000, + BlackLine = 0x00000001, + BlackFill = 0x00000002, + BlackText = 0x00000004, + BlackBitmap = 0x00000008, + BlackGradient = 0x00000010, + GrayLine = 0x00000020, + GrayFill = 0x00000040, + GrayText = 0x00000080, + GrayBitmap = 0x00000100, + GrayGradient = 0x00000200, + NoFill = 0x00000400, + WhiteLine = 0x00000800, + WhiteFill = 0x00001000, + WhiteText = 0x00002000, + WhiteBitmap = 0x00004000, + WhiteGradient = 0x00008000, + SettingsLine = 0x00010000, + SettingsFill = 0x00020000, + SettingsText = 0x00040000, + SettingsGradient = 0x00080000, + NoTransparency = 0x00100000, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawModeFlags> : is_typed_flags<DrawModeFlags, 0x1fffff> {}; +} + +// Antialiasing +enum class AntialiasingFlags +{ + NONE = 0x0000, + DisableText = 0x0001, + EnableB2dDraw = 0x0002, + PixelSnapHairline = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags<AntialiasingFlags> : is_typed_flags<AntialiasingFlags, 0x07> {}; +} + +// AddFontSubstitute() flags +enum class AddFontSubstituteFlags +{ + NONE = 0x00, + ALWAYS = 0x01, + ScreenOnly = 0x02, +}; +namespace o3tl +{ + template<> struct typed_flags<AddFontSubstituteFlags> : is_typed_flags<AddFontSubstituteFlags, 0x03> {}; +} + +// GetDefaultFont() flags +enum class GetDefaultFontFlags +{ + NONE = 0x0000, + OnlyOne = 0x0001, +}; +namespace o3tl +{ + template<> struct typed_flags<GetDefaultFontFlags> : is_typed_flags<GetDefaultFontFlags, 0x01> {}; +} + +// Flags for Invert() +enum class InvertFlags +{ + NONE = 0x0000, + N50 = 0x0001, + TrackFrame = 0x0002 +}; +namespace o3tl +{ + template<> struct typed_flags<InvertFlags> : is_typed_flags<InvertFlags, 0x0003> {}; +} + +enum OutDevType { OUTDEV_WINDOW, OUTDEV_PRINTER, OUTDEV_VIRDEV, OUTDEV_PDF }; + +enum class OutDevViewType { DontKnow, PrintPreview, SlideShow }; + +// OutputDevice + +typedef tools::SvRef<FontCharMap> FontCharMapRef; + +BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ); +void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect ); + +class OutputDevice; + +namespace vcl { + typedef OutputDevice RenderContext; +} + +VCL_DLLPUBLIC void DrawFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + +typedef struct _cairo_surface cairo_surface_t; + +/** +* Some things multiple-inherit from VclAbstractDialog and OutputDevice, +* so we need to use virtual inheritance to keep the referencing counting +* OK. +*/ +class SAL_WARN_UNUSED VCL_DLLPUBLIC OutputDevice : public virtual VclReferenceBase +{ + friend class Printer; + friend class VirtualDevice; + friend class vcl::Window; + friend class WorkWindow; + friend void ImplHandleResize( vcl::Window* pWindow, long nNewWidth, long nNewHeight ); + +private: + OutputDevice(const OutputDevice&) = delete; + OutputDevice& operator=(const OutputDevice&) = delete; + + mutable SalGraphics* mpGraphics; ///< Graphics context to draw on + mutable VclPtr<OutputDevice> mpPrevGraphics; ///< Previous output device in list + mutable VclPtr<OutputDevice> mpNextGraphics; ///< Next output device in list + GDIMetaFile* mpMetaFile; + mutable rtl::Reference<LogicalFontInstance> mpFontInstance; + mutable std::shared_ptr<ImplFontCache> mxFontCache; + mutable std::shared_ptr<PhysicalFontCollection> mxFontCollection; + mutable std::unique_ptr<ImplDeviceFontList> mpDeviceFontList; + mutable std::unique_ptr<ImplDeviceFontSizeList> mpDeviceFontSizeList; + std::vector<OutDevState> maOutDevStateStack; + std::unique_ptr<ImplOutDevData> mpOutDevData; + std::vector< VCLXGraphics* >* mpUnoGraphicsList; + vcl::ExtOutDevData* mpExtOutDevData; + + // TEMP TEMP TEMP + VclPtr<VirtualDevice> mpAlphaVDev; + + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + long mnOutOffOrigX; + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + long mnOutOffLogicX; + /// Additional output pixel offset, applied in LogicToPixel (used by SetPixelOffset/GetPixelOffset) + long mnOutOffOrigY; + /// Additional output offset in _logical_ coordinates, applied in PixelToLogic (used by SetPixelOffset/GetPixelOffset) + long mnOutOffLogicY; + /// Output offset for device output in pixel (pseudo window offset within window system's frames) + long mnOutOffX; + /// Output offset for device output in pixel (pseudo window offset within window system's frames) + long mnOutOffY; + long mnOutWidth; + long mnOutHeight; + sal_Int32 mnDPIX; + sal_Int32 mnDPIY; + sal_Int32 mnDPIScalePercentage; ///< For HiDPI displays, we want to draw elements for a percentage larger + /// font specific text alignment offsets in pixel units + mutable long mnTextOffX; + mutable long mnTextOffY; + mutable long mnEmphasisAscent; + mutable long mnEmphasisDescent; + DrawModeFlags mnDrawMode; + ComplexTextLayoutFlags mnTextLayoutMode; + ImplMapRes maMapRes; + ImplThresholdRes maThresRes; + const OutDevType meOutDevType; + OutDevViewType meOutDevViewType; + vcl::Region maRegion; // contains the clip region, see SetClipRegion(...) + Color maLineColor; + Color maFillColor; + vcl::Font maFont; + Color maTextColor; + Color maTextLineColor; + Color maOverlineColor; + RasterOp meRasterOp; + Wallpaper maBackground; + std::unique_ptr<AllSettings> mxSettings; + MapMode maMapMode; + Point maRefPoint; + AntialiasingFlags mnAntialiasing; + LanguageType meTextLanguage; + + mutable bool mbMap : 1; + mutable bool mbClipRegion : 1; + mutable bool mbBackground : 1; + mutable bool mbOutput : 1; + mutable bool mbDevOutput : 1; + mutable bool mbOutputClipped : 1; + mutable bool mbLineColor : 1; + mutable bool mbFillColor : 1; + mutable bool mbInitLineColor : 1; + mutable bool mbInitFillColor : 1; + mutable bool mbInitFont : 1; + mutable bool mbInitTextColor : 1; + mutable bool mbInitClipRegion : 1; + mutable bool mbClipRegionSet : 1; + mutable bool mbNewFont : 1; + mutable bool mbTextLines : 1; + mutable bool mbTextSpecial : 1; + mutable bool mbRefPoint : 1; + mutable bool mbEnableRTL : 1; + + /** @name Initialization and accessor functions + */ + ///@{ + +protected: + OutputDevice(OutDevType eOutDevType); + virtual ~OutputDevice() override; + virtual void dispose() override; + +public: + + /** Get the graphic context that the output device uses to draw on. + + If no graphics device exists, then initialize it. + + @returns SalGraphics instance. + */ + SalGraphics const *GetGraphics() const; + SalGraphics* GetGraphics(); + + void SetConnectMetaFile( GDIMetaFile* pMtf ); + GDIMetaFile* GetConnectMetaFile() const { return mpMetaFile; } + + virtual void SetSettings( const AllSettings& rSettings ); + const AllSettings& GetSettings() const { return *mxSettings; } + + SystemGraphicsData GetSystemGfxData() const; + bool SupportsCairo() const; + /// Create Surface from given cairo surface + cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const; + /// Create surface with given dimensions + cairo::SurfaceSharedPtr CreateSurface(int x, int y, int width, int height) const; + /// Create Surface for given bitmap data + cairo::SurfaceSharedPtr CreateBitmapSurface(const BitmapSystemData& rData, const Size& rSize) const; + /// Return native handle for underlying surface + css::uno::Any GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& rSurface, const basegfx::B2ISize& rSize) const; + css::uno::Any GetSystemGfxDataAny() const; + + void SetRefPoint(); + void SetRefPoint( const Point& rRefPoint ); + const Point& GetRefPoint() const { return maRefPoint; } + bool IsRefPoint() const { return mbRefPoint; } + + virtual bool IsScreenComp() const { return true; } + + virtual sal_uInt16 GetBitCount() const; + + Size GetOutputSizePixel() const + { return Size( mnOutWidth, mnOutHeight ); } + long GetOutputWidthPixel() const { return mnOutWidth; } + long GetOutputHeightPixel() const { return mnOutHeight; } + long GetOutOffXPixel() const { return mnOutOffX; } + long GetOutOffYPixel() const { return mnOutOffY; } + void SetOutOffXPixel(long nOutOffX); + void SetOutOffYPixel(long nOutOffY); + + Size GetOutputSize() const + { return PixelToLogic( GetOutputSizePixel() ); } + + css::uno::Reference< css::awt::XGraphics > + CreateUnoGraphics(); + std::vector< VCLXGraphics* > *GetUnoGraphicsList() const { return mpUnoGraphicsList; } + std::vector< VCLXGraphics* > *CreateUnoGraphicsList(); + +protected: + + /** Acquire a graphics device that the output device uses to draw on. + + There is an LRU of OutputDevices that is used to get the graphics. The + actual creation of a SalGraphics instance is done via the SalFrame + implementation. + + However, the SalFrame instance will only return a valid SalGraphics + instance if it is not in use or there wasn't one in the first place. When + this happens, AcquireGraphics finds the least recently used OutputDevice + in a different frame and "steals" it (releases it then starts using it). + + If there are no frames to steal an OutputDevice's SalGraphics instance from + then it blocks until the graphics is released. + + Once it has acquired a graphics instance, then we add the OutputDevice to + the LRU. + + @returns true if was able to initialize the graphics device, false otherwise. + */ + virtual bool AcquireGraphics() const = 0; + + /** Release the graphics device, and remove it from the graphics device + list. + + @param bRelease Determines whether to release the fonts of the + physically released graphics device. + */ + virtual void ReleaseGraphics( bool bRelease = true ) = 0; + ///@} + + + /** @name Helper functions + */ + ///@{ + +public: + + /** Get the output device's DPI x-axis value. + + @returns x-axis DPI value + */ + SAL_DLLPRIVATE sal_Int32 GetDPIX() const { return mnDPIX; } + + /** Get the output device's DPI y-axis value. + + @returns y-axis DPI value + */ + SAL_DLLPRIVATE sal_Int32 GetDPIY() const { return mnDPIY; } + + SAL_DLLPRIVATE void SetDPIX( sal_Int32 nDPIX ) { mnDPIX = nDPIX; } + SAL_DLLPRIVATE void SetDPIY( sal_Int32 nDPIY ) { mnDPIY = nDPIY; } + + float GetDPIScaleFactor() const + { + return mnDPIScalePercentage / 100.0f; + } + + sal_Int32 GetDPIScalePercentage() const + { + return mnDPIScalePercentage; + } + + OutDevType GetOutDevType() const { return meOutDevType; } + virtual bool IsVirtual() const; + + /** Query an OutputDevice to see whether it supports a specific operation + + @returns true if operation supported, else false + */ + bool SupportsOperation( OutDevSupportType ) const; + + void SetExtOutDevData( vcl::ExtOutDevData* pExtOutDevData ) { mpExtOutDevData = pExtOutDevData; } + vcl::ExtOutDevData* GetExtOutDevData() const { return mpExtOutDevData; } + + ///@} + + + /** @name Direct OutputDevice drawing functions + */ + ///@{ + +public: + virtual void Flush() {} + + virtual void DrawOutDev( + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize ); + + virtual void DrawOutDev( + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize, + const OutputDevice& rOutDev ); + + virtual void CopyArea( + const Point& rDestPt, + const Point& rSrcPt, const Size& rSrcSize, + bool bWindowInvalidate = false ); + +protected: + + virtual void CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate); + + virtual tools::Rectangle GetBackgroundComponentBounds() const; + + virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const; + + virtual void DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ); + + SAL_DLLPRIVATE void drawOutDevDirect ( const OutputDevice* pSrcDev, SalTwoRect& rPosAry ); + + SAL_DLLPRIVATE bool is_double_buffered_window() const; + +private: + + // not implemented; to detect misuses of DrawOutDev(...OutputDevice&); + SAL_DLLPRIVATE void DrawOutDev( const Point&, const Size&, const Point&, const Size&, const Printer&) = delete; + ///@} + + + /** @name OutputDevice state functions + */ + ///@{ + +public: + + void Push( PushFlags nFlags = PushFlags::ALL ); + void Pop(); + + // returns the current stack depth; that is the number of Push() calls minus the number of Pop() calls + // this should not normally be used since Push and Pop must always be used symmetrically + // however this may be e.g. a help when debugging code in which this somehow is not the case + sal_uInt32 GetGCStackDepth() const; + void ClearStack(); + + void EnableOutput( bool bEnable = true ); + bool IsOutputEnabled() const { return mbOutput; } + bool IsDeviceOutputNecessary() const { return (mbOutput && mbDevOutput); } + + void SetAntialiasing( AntialiasingFlags nMode ); + AntialiasingFlags GetAntialiasing() const { return mnAntialiasing; } + + void SetDrawMode( DrawModeFlags nDrawMode ); + DrawModeFlags GetDrawMode() const { return mnDrawMode; } + + void SetLayoutMode( ComplexTextLayoutFlags nTextLayoutMode ); + ComplexTextLayoutFlags GetLayoutMode() const { return mnTextLayoutMode; } + + void SetDigitLanguage( LanguageType ); + LanguageType GetDigitLanguage() const { return meTextLanguage; } + + void SetRasterOp( RasterOp eRasterOp ); + RasterOp GetRasterOp() const { return meRasterOp; } + + /** + If this OutputDevice is used for displaying a Print Preview + the OutDevViewType should be set to 'OutDevViewType::PrintPreview'. + + A View can then make painting decisions dependent on this OutDevViewType. + E.g. text colors need to be handled differently, dependent on whether it's a PrintPreview or not. (see #106611# for more) + */ + void SetOutDevViewType( OutDevViewType eOutDevViewType ) { meOutDevViewType=eOutDevViewType; } + OutDevViewType GetOutDevViewType() const { return meOutDevViewType; } + + void SetLineColor(); + void SetLineColor( const Color& rColor ); + const Color& GetLineColor() const { return maLineColor; } + bool IsLineColor() const { return mbLineColor; } + + void SetFillColor(); + void SetFillColor( const Color& rColor ); + const Color& GetFillColor() const { return maFillColor; } + bool IsFillColor() const { return mbFillColor; } + + void SetBackground(); + void SetBackground( const Wallpaper& rBackground ); + virtual void SaveBackground(VirtualDevice& rSaveDevice, + const Point& rPos, const Size& rSize, const Size& rBackgroundSize) const; + + const Wallpaper& GetBackground() const { return maBackground; } + virtual Color GetBackgroundColor() const; + virtual Color GetReadableFontColor(const Color& rFontColor, const Color& rBgColor) const; + bool IsBackground() const { return mbBackground; } + + void SetFont( const vcl::Font& rNewFont ); + const vcl::Font& GetFont() const { return maFont; } + +protected: + + virtual void ImplReleaseFonts(); + +private: + + SAL_DLLPRIVATE void InitLineColor(); + + SAL_DLLPRIVATE void InitFillColor(); + + ///@} + + + /** @name Clipping functions + */ + ///@{ + +public: + + vcl::Region GetClipRegion() const; + void SetClipRegion(); + void SetClipRegion( const vcl::Region& rRegion ); + bool SelectClipRegion( const vcl::Region&, SalGraphics* pGraphics = nullptr ); + + bool IsClipRegion() const { return mbClipRegion; } + + void MoveClipRegion( long nHorzMove, long nVertMove ); + void IntersectClipRegion( const tools::Rectangle& rRect ); + void IntersectClipRegion( const vcl::Region& rRegion ); + + virtual vcl::Region GetActiveClipRegion() const; + virtual vcl::Region GetOutputBoundsClipRegion() const; + +protected: + + virtual void InitClipRegion(); + + /** Perform actual rect clip against outdev dimensions, to generate + empty clips whenever one of the values is completely off the device. + + @param aRegion region to be clipped to the device dimensions + @returns region clipped to the device bounds + **/ + virtual vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const; + virtual void ClipToPaintRegion ( tools::Rectangle& rDstRect ); + +private: + + SAL_DLLPRIVATE void SetDeviceClipRegion( const vcl::Region* pRegion ); + ///@} + + + /** @name Pixel functions + */ + ///@{ + +public: + + void DrawPixel( const Point& rPt ); + void DrawPixel( const Point& rPt, const Color& rColor ); + + Color GetPixel( const Point& rPt ) const; + ///@} + + + /** @name Rectangle functions + */ + ///@{ + +public: + + void DrawRect( const tools::Rectangle& rRect ); + void DrawRect( const tools::Rectangle& rRect, + sal_uLong nHorzRount, sal_uLong nVertRound ); + + /// Fill the given rectangle with checkered rectangles of size nLen x nLen using the colors aStart and aEnd + void DrawCheckered( + const Point& rPos, + const Size& rSize, + sal_uInt32 nLen = 8, + Color aStart = COL_WHITE, + Color aEnd = COL_BLACK); + + void DrawGrid( const tools::Rectangle& rRect, const Size& rDist, DrawGridFlags nFlags ); + + ///@} + + /** @name Invert functions + */ + ///@{ +public: + void Invert( const tools::Rectangle& rRect, InvertFlags nFlags = InvertFlags::NONE ); + void Invert( const tools::Polygon& rPoly, InvertFlags nFlags = InvertFlags::NONE ); + ///@} + + /** @name Line functions + */ + ///@{ + +public: + + void DrawLine( const Point& rStartPt, const Point& rEndPt ); + + void DrawLine( const Point& rStartPt, const Point& rEndPt, + const LineInfo& rLineInfo ); + +protected: + virtual void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& rEndPoint); + +private: + + /** Helper for line geometry paint with support for graphic expansion (pattern and fat_to_area) + */ + SAL_DLLPRIVATE void drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const LineInfo& rInfo ); + ///@} + + + /** @name Polyline functions + */ + ///@{ + +public: + + /** Render the given polygon as a line stroke + + The given polygon is stroked with the current LineColor, start + and end point are not automatically connected + + @see DrawPolygon + @see DrawPolyPolygon + */ + void DrawPolyLine( const tools::Polygon& rPoly ); + + void DrawPolyLine( + const basegfx::B2DPolygon&, + double fLineWidth = 0.0, + basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::Round, + css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT, + double fMiterMinimumAngle = basegfx::deg2rad(15.0)); + + /** Render the given polygon as a line stroke + + The given polygon is stroked with the current LineColor, start + and end point are not automatically connected. The line is + rendered according to the specified LineInfo, e.g. supplying a + dash pattern, or a line thickness. + + @see DrawPolygon + @see DrawPolyPolygon + */ + void DrawPolyLine( const tools::Polygon& rPoly, + const LineInfo& rLineInfo ); + + // #i101491# + // Helper who tries to use SalGDI's DrawPolyLine direct and returns it's bool. + bool DrawPolyLineDirect( + const basegfx::B2DHomMatrix& rObjectTransform, + const basegfx::B2DPolygon& rB2DPolygon, + double fLineWidth = 0.0, + double fTransparency = 0.0, + const std::vector< double >* = nullptr, // MM01 + basegfx::B2DLineJoin eLineJoin = basegfx::B2DLineJoin::NONE, + css::drawing::LineCap eLineCap = css::drawing::LineCap_BUTT, + double fMiterMinimumAngle = basegfx::deg2rad(15.0), + bool bBypassAACheck = false); + +private: + + // #i101491# + // Helper which holds the old line geometry creation and is extended to use AA when + // switched on. Advantage is that line geometry is only temporarily used for paint + SAL_DLLPRIVATE void drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLineInfo); + + ///@} + + + /** @name Polygon functions + */ + ///@{ + +public: + + /** Render the given polygon + + The given polygon is stroked with the current LineColor, and + filled with the current FillColor. If one of these colors are + transparent, the corresponding stroke or fill stays + invisible. Start and end point of the polygon are + automatically connected. + + @see DrawPolyLine + */ + void DrawPolygon( const tools::Polygon& rPoly ); + void DrawPolygon( const basegfx::B2DPolygon& ); + + /** Render the given poly-polygon + + The given poly-polygon is stroked with the current LineColor, + and filled with the current FillColor. If one of these colors + are transparent, the corresponding stroke or fill stays + invisible. Start and end points of the contained polygons are + automatically connected. + + @see DrawPolyLine + */ + void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly ); + void DrawPolyPolygon( const basegfx::B2DPolyPolygon& ); + +private: + + SAL_DLLPRIVATE void ImplDrawPolygon( const tools::Polygon& rPoly, const tools::PolyPolygon* pClipPolyPoly = nullptr ); + SAL_DLLPRIVATE void ImplDrawPolyPolygon( const tools::PolyPolygon& rPolyPoly, const tools::PolyPolygon* pClipPolyPoly ); + SAL_DLLPRIVATE void ImplDrawPolyPolygon( sal_uInt16 nPoly, const tools::PolyPolygon& rPolyPoly ); + // #i101491# + // Helper who implements the DrawPolyPolygon functionality for basegfx::B2DPolyPolygon + // without MetaFile processing + SAL_DLLPRIVATE void ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly); + ///@} + + + /** @name Curved shape functions + */ + ///@{ + +public: + + void DrawEllipse( const tools::Rectangle& rRect ); + + void DrawArc( + const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + void DrawPie( + const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + void DrawChord( + const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + ///@} + + + /** @name Gradient functions + */ + ///@{ + +public: + void DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient ); + void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); + + void AddGradientActions( + const tools::Rectangle& rRect, + const Gradient& rGradient, + GDIMetaFile& rMtf ); + +protected: + + virtual bool UsePolyPolygonForComplexGradient() = 0; + + virtual long GetGradientStepCount( long nMinRect ); + +private: + + SAL_DLLPRIVATE void DrawLinearGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly ); + SAL_DLLPRIVATE void DrawComplexGradient( const tools::Rectangle& rRect, const Gradient& rGradient, const tools::PolyPolygon* pClipPolyPoly ); + + SAL_DLLPRIVATE void DrawGradientToMetafile( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); + SAL_DLLPRIVATE void DrawLinearGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient ); + SAL_DLLPRIVATE void DrawComplexGradientToMetafile( const tools::Rectangle& rRect, const Gradient& rGradient ); + + SAL_DLLPRIVATE long GetGradientSteps( const Gradient& rGradient, const tools::Rectangle& rRect, bool bMtf, bool bComplex=false ); + + SAL_DLLPRIVATE Color GetSingleColorGradientFill(); + SAL_DLLPRIVATE void SetGrayscaleColors( Gradient &rGradient ); + ///@} + + + /** @name Hatch functions + */ + ///@{ + +public: + +#ifdef _MSC_VER + void DrawHatch( const tools::PolyPolygon& rPolyPoly, const ::Hatch& rHatch ); + void AddHatchActions( const tools::PolyPolygon& rPolyPoly, + const ::Hatch& rHatch, + GDIMetaFile& rMtf ); +#else + void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ); + void AddHatchActions( const tools::PolyPolygon& rPolyPoly, + const Hatch& rHatch, + GDIMetaFile& rMtf ); +#endif + + void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch, bool bMtf ); + +private: + + SAL_DLLPRIVATE void CalcHatchValues( const tools::Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); + SAL_DLLPRIVATE void DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf ); + ///@} + + + /** @name Wallpaper functions + */ + ///@{ + +public: + void DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper ); + + void Erase(); + void Erase(const tools::Rectangle& rRect); + +protected: + void DrawGradientWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + +private: + SAL_DLLPRIVATE void DrawWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void DrawColorWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + SAL_DLLPRIVATE void DrawBitmapWallpaper( long nX, long nY, long nWidth, long nHeight, const Wallpaper& rWallpaper ); + ///@} + + + /** @name Text functions + */ + ///@{ + +public: + + void DrawText( const Point& rStartPt, const OUString& rStr, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr, + const SalLayoutGlyphs* pLayoutCache = nullptr ); + + void DrawText( const tools::Rectangle& rRect, + const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::NONE, + MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr, + vcl::ITextLayout* _pTextLayout = nullptr ); + + static void ImplDrawText( OutputDevice& rTargetDevice, const tools::Rectangle& rRect, + const OUString& rOrigStr, DrawTextFlags nStyle, + MetricVector* pVector, OUString* pDisplayText, vcl::ITextLayout& _rLayout ); + + void ImplDrawText( SalLayout& ); + + void ImplDrawTextBackground( const SalLayout& ); + + void DrawCtrlText( const Point& rPos, const OUString& rStr, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + DrawTextFlags nStyle = DrawTextFlags::Mnemonic, MetricVector* pVector = nullptr, OUString* pDisplayText = nullptr, + const SalLayoutGlyphs* pGlyphs = nullptr); + + void DrawTextLine( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontLineStyle eUnderline, + FontLineStyle eOverline, + bool bUnderlineAbove = false ); + + void ImplDrawTextLine( long nBaseX, long nX, long nY, DeviceCoordinate nWidth, + FontStrikeout eStrikeout, FontLineStyle eUnderline, + FontLineStyle eOverline, bool bUnderlineAbove ); + + void ImplDrawTextLines( SalLayout&, FontStrikeout eStrikeout, FontLineStyle eUnderline, + FontLineStyle eOverline, bool bWordLine, bool bUnderlineAbove ); + + void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, long nLineWidth = 1 ); + + bool ImplDrawRotateText( SalLayout& ); + + tools::Rectangle GetTextRect( const tools::Rectangle& rRect, + const OUString& rStr, DrawTextFlags nStyle = DrawTextFlags::WordBreak, + TextRectInfo* pInfo = nullptr, + const vcl::ITextLayout* _pTextLayout = nullptr ) const; + + /** Return the exact bounding rectangle of rStr. + + The text is then drawn exactly from rRect.TopLeft() to + rRect.BottomRight(), don't assume that rRect.TopLeft() is [0, 0]. + + Please note that you don't always want to use GetTextBoundRect(); in + many cases you actually want to use GetTextHeight(), because + GetTextBoundRect() gives you the exact bounding rectangle regardless + what is the baseline of the text. + + Code snippet to get just exactly the text (no filling around that) as + a bitmap via a VirtualDevice (regardless what is the baseline): + + <code> + VirtualDevice aDevice; + vcl::Font aFont = aDevice.GetFont(); + aFont.SetSize(Size(0, 96)); + aFont.SetColor(COL_BLACK); + aDevice.SetFont(aFont); + aDevice.Erase(); + + tools::Rectangle aRect; + aDevice.GetTextBoundRect(aRect, aText); + aDevice.SetOutputSize(Size(aRect.BottomRight().X() + 1, aRect.BottomRight().Y() + 1)); + aDevice.SetBackground(Wallpaper(COL_TRANSPARENT)); + aDevice.DrawText(Point(0,0), aText); + + // exactly only the text, regardless of the baseline + Bitmap aBitmap(aDevice.GetBitmap(aRect.TopLeft(), aRect.GetSize())); + </code> + + Code snippet to get the text as a bitmap via a Virtual device that + contains even the filling so that the baseline is always preserved + (ie. the text will not jump up and down according to whether it + contains 'y' or not etc.) + + <code> + VirtualDevice aDevice; + // + the appropriate font / device setup, see above + + aDevice.SetOutputSize(Size(aDevice.GetTextWidth(aText), aDevice.GetTextHeight())); + aDevice.SetBackground(Wallpaper(COL_TRANSPARENT)); + aDevice.DrawText(Point(0,0), aText); + + // bitmap that contains even the space around the text, + // that means, preserves the baseline etc. + Bitmap aBitmap(aDevice.GetBitmap(Point(0, 0), aDevice.GetOutputSize())); + </code> + */ + bool GetTextBoundRect( tools::Rectangle& rRect, + const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr, + const SalLayoutGlyphs* pGlyphs = nullptr ) const; + + tools::Rectangle ImplGetTextBoundRect( const SalLayout& ); + + bool GetTextOutline( tools::PolyPolygon&, + const OUString& rStr, + sal_Int32 nLen = -1, + sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const; + + bool GetTextOutlines( PolyPolyVector&, + const OUString& rStr, sal_Int32 nBase = 0, sal_Int32 nIndex = 0, + sal_Int32 nLen = -1, + sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const; + + bool GetTextOutlines( basegfx::B2DPolyPolygonVector &rVector, + const OUString& rStr, sal_Int32 nBase, sal_Int32 nIndex = 0, + sal_Int32 nLen = -1, + sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const; + + + OUString GetEllipsisString( const OUString& rStr, long nMaxWidth, + DrawTextFlags nStyle = DrawTextFlags::EndEllipsis ) const; + + long GetCtrlTextWidth( const OUString& rStr, + const SalLayoutGlyphs* pLayoutCache = nullptr ) const; + + static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos ); + + static OUString GetNonMnemonicString( const OUString& rStr ) + { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); } + + /** Generate MetaTextActions for the text rect + + This method splits up the text rect into multiple + MetaTextActions, one for each line of text. This is comparable + to AddGradientActions(), which splits up a gradient into its + constituent polygons. Parameter semantics fully compatible to + DrawText(). + */ + void AddTextRectActions( const tools::Rectangle& rRect, + const OUString& rOrigStr, + DrawTextFlags nStyle, + GDIMetaFile& rMtf ); + + void SetTextColor( const Color& rColor ); + const Color& GetTextColor() const { return maTextColor; } + + void SetTextFillColor(); + void SetTextFillColor( const Color& rColor ); + Color GetTextFillColor() const; + bool IsTextFillColor() const { return !maFont.IsTransparent(); } + + void SetTextLineColor(); + void SetTextLineColor( const Color& rColor ); + const Color& GetTextLineColor() const { return maTextLineColor; } + bool IsTextLineColor() const { return (maTextLineColor.GetTransparency() == 0); } + + void SetOverlineColor(); + void SetOverlineColor( const Color& rColor ); + const Color& GetOverlineColor() const { return maOverlineColor; } + bool IsOverlineColor() const { return (maOverlineColor.GetTransparency() == 0); } + + void SetTextAlign( TextAlign eAlign ); + TextAlign GetTextAlign() const { return maFont.GetAlignment(); } + + /** Width of the text. + + See also GetTextBoundRect() for more explanation + code examples. + */ + long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::TextLayoutCache const* = nullptr, + SalLayoutGlyphs const*const pLayoutCache = nullptr) const; + + /** Height where any character of the current font fits; in logic coordinates. + + See also GetTextBoundRect() for more explanation + code examples. + */ + long GetTextHeight() const; + float approximate_digit_width() const; + + void DrawTextArray( const Point& rStartPt, const OUString& rStr, + const long* pDXAry, + sal_Int32 nIndex = 0, + sal_Int32 nLen = -1, + SalLayoutFlags flags = SalLayoutFlags::NONE, + const SalLayoutGlyphs* pLayoutCache = nullptr); + long GetTextArray( const OUString& rStr, long* pDXAry, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::TextLayoutCache const* = nullptr, + SalLayoutGlyphs const*const pLayoutCache = nullptr) const; + + void GetCaretPositions( const OUString&, long* pCaretXArray, + sal_Int32 nIndex, sal_Int32 nLen, + const SalLayoutGlyphs* pGlyphs = nullptr ) const; + void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, + const OUString& rStr, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1); + sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Int32 nIndex, sal_Int32 nLen = -1, + long nCharExtra = 0, + vcl::TextLayoutCache const* = nullptr, + const SalLayoutGlyphs* pGlyphs = nullptr) const; + sal_Int32 GetTextBreak( const OUString& rStr, long nTextWidth, + sal_Unicode nExtraChar, sal_Int32& rExtraCharPos, + sal_Int32 nIndex, sal_Int32 nLen, + long nCharExtra, + vcl::TextLayoutCache const* = nullptr) const; + static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&); + +protected: + SAL_DLLPRIVATE void ImplInitTextLineSize(); + SAL_DLLPRIVATE void ImplInitAboveTextLineSize(); + static + SAL_DLLPRIVATE long ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const OUString& rStr, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout ); + SAL_DLLPRIVATE float approximate_char_width() const; +private: + SAL_DLLPRIVATE void ImplInitTextColor(); + + SAL_DLLPRIVATE void ImplDrawTextDirect( SalLayout&, bool bTextLines); + SAL_DLLPRIVATE void ImplDrawSpecialText( SalLayout& ); + SAL_DLLPRIVATE void ImplDrawTextRect( long nBaseX, long nBaseY, long nX, long nY, long nWidth, long nHeight ); + + SAL_DLLPRIVATE static void ImplDrawWavePixel( long nOriginX, long nOriginY, long nCurX, long nCurY, short nOrientation, SalGraphics* pGraphics, OutputDevice const * pOutDev, + bool bDrawPixAsRect, long nPixWidth, long nPixHeight ); + SAL_DLLPRIVATE void ImplDrawWaveLine( long nBaseX, long nBaseY, long nStartX, long nStartY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor ); + SAL_DLLPRIVATE void ImplDrawWaveTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove ); + SAL_DLLPRIVATE void ImplDrawStraightTextLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontLineStyle eTextLine, Color aColor, bool bIsAbove ); + SAL_DLLPRIVATE void ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); + SAL_DLLPRIVATE void ImplDrawStrikeoutChar( long nBaseX, long nBaseY, long nX, long nY, long nWidth, FontStrikeout eStrikeout, Color aColor ); + SAL_DLLPRIVATE void ImplDrawMnemonicLine( long nX, long nY, long nWidth ); + + + ///@} + + + /** @name Font functions + */ + ///@{ + +public: + + FontMetric GetDevFont( int nDevFontIndex ) const; + int GetDevFontCount() const; + + bool IsFontAvailable( const OUString& rFontName ) const; + + Size GetDevFontSize( const vcl::Font& rFont, int nSizeIndex ) const; + int GetDevFontSizeCount( const vcl::Font& ) const; + + bool AddTempDevFont( const OUString& rFileURL, const OUString& rFontName ); + void RefreshFontData( const bool bNewFontLists ); + + FontMetric GetFontMetric() const; + FontMetric GetFontMetric( const vcl::Font& rFont ) const; + + bool GetFontCharMap( FontCharMapRef& rxFontCharMap ) const; + bool GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const; + + bool GetFontFeatures(std::vector<vcl::font::Feature>& rFontFeatures) const; + + + /** Retrieve detailed font information in platform independent structure + + @param nFallbacklevel Fallback font level (0 = best matching font) + + @return SystemFontData + */ + SystemFontData GetSysFontData( int nFallbacklevel ) const; + + SAL_DLLPRIVATE void ImplGetEmphasisMark( tools::PolyPolygon& rPolyPoly, bool& rPolyLine, tools::Rectangle& rRect1, tools::Rectangle& rRect2, + long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight ); + SAL_DLLPRIVATE static FontEmphasisMark + ImplGetEmphasisMarkStyle( const vcl::Font& rFont ); + + bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, + int nLen, MetricVector& rVector ); + + sal_Int32 HasGlyphs( const vcl::Font& rFont, const OUString& rStr, + sal_Int32 nIndex = 0, sal_Int32 nLen = -1 ) const; + + long GetMinKashida() const; + + // i60594 + // validate kashida positions against the current font + // returns count of invalid kashida positions + sal_Int32 ValidateKashidas( const OUString& rTxt, sal_Int32 nIdx, sal_Int32 nLen, + sal_Int32 nKashCount, // number of suggested kashida positions (in) + const sal_Int32* pKashidaPos, // suggested kashida positions (in) + sal_Int32* pKashidaPosDropped // invalid kashida positions (out) + ) const; + + static void BeginFontSubstitution(); + static void EndFontSubstitution(); + static void AddFontSubstitute( const OUString& rFontName, + const OUString& rReplaceFontName, + AddFontSubstituteFlags nFlags ); + static void RemoveFontsSubstitute(); + + static vcl::Font GetDefaultFont( DefaultFontType nType, + LanguageType eLang, + GetDefaultFontFlags nFlags, + const OutputDevice* pOutDev = nullptr ); + + SAL_DLLPRIVATE void ImplInitFontList() const; + SAL_DLLPRIVATE void ImplUpdateFontData(); + + //drop font data for all outputdevices. + //If bNewFontLists is true then empty lists of system fonts + SAL_DLLPRIVATE static void ImplClearAllFontData( bool bNewFontLists ); + //fetch font data for all outputdevices + //If bNewFontLists is true then fetch lists of system fonts + SAL_DLLPRIVATE static void ImplRefreshAllFontData( bool bNewFontLists ); + //drop and fetch font data for all outputdevices + //If bNewFontLists is true then drop and refetch lists of system fonts + SAL_DLLPRIVATE static void ImplUpdateAllFontData( bool bNewFontLists ); + +protected: + SAL_DLLPRIVATE const LogicalFontInstance* GetFontInstance() const; + SAL_DLLPRIVATE long GetEmphasisAscent() const { return mnEmphasisAscent; } + SAL_DLLPRIVATE long GetEmphasisDescent() const { return mnEmphasisDescent; } + + SAL_DLLPRIVATE bool InitFont() const; + virtual void SetFontOrientation( LogicalFontInstance* const pFontInstance ) const; + virtual long GetFontExtLeading() const; + + virtual void ImplClearFontData(bool bNewFontLists); + virtual void ImplRefreshFontData(bool bNewFontLists); + void ReleaseFontCache(); + void ReleaseFontCollection(); + void SetFontCollectionFromSVData(); + void ResetNewFontCache(); + +private: + + typedef void ( OutputDevice::* FontUpdateHandler_t )( bool ); + + SAL_DLLPRIVATE bool ImplNewFont() const; + + SAL_DLLPRIVATE static void ImplUpdateFontDataForAllFrames( FontUpdateHandler_t pHdl, bool bNewFontLists ); + + static + SAL_DLLPRIVATE OUString ImplGetEllipsisString( const OutputDevice& rTargetDevice, const OUString& rStr, + long nMaxWidth, DrawTextFlags nStyle, const vcl::ITextLayout& _rLayout ); + + SAL_DLLPRIVATE void ImplDrawEmphasisMark( long nBaseX, long nX, long nY, const tools::PolyPolygon& rPolyPoly, bool bPolyLine, const tools::Rectangle& rRect1, const tools::Rectangle& rRect2 ); + SAL_DLLPRIVATE void ImplDrawEmphasisMarks( SalLayout& ); + ///@} + + + /** @name Layout functions + */ + ///@{ + +public: + + SystemTextLayoutData GetSysTextLayoutData( const Point& rStartPt, const OUString& rStr, + sal_Int32 nIndex, sal_Int32 nLen, + const long* pDXAry ) const; + + // tells whether this output device is RTL in an LTR UI or LTR in a RTL UI + SAL_DLLPRIVATE bool ImplIsAntiparallel() const ; + SAL_DLLPRIVATE void ReMirror( Point &rPoint ) const; + SAL_DLLPRIVATE void ReMirror( tools::Rectangle &rRect ) const; + SAL_DLLPRIVATE void ReMirror( vcl::Region &rRegion ) const; + SAL_DLLPRIVATE bool ImplIsRecordLayout() const; + virtual bool HasMirroredGraphics() const; + std::unique_ptr<SalLayout> + ImplLayout( const OUString&, sal_Int32 nIndex, sal_Int32 nLen, + const Point& rLogicPos = Point(0,0), long nLogicWidth=0, + const long* pLogicDXArray=nullptr, SalLayoutFlags flags = SalLayoutFlags::NONE, + vcl::TextLayoutCache const* = nullptr, + const SalLayoutGlyphs* pGlyphs = nullptr) const; + SAL_DLLPRIVATE ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen, + DeviceCoordinate nPixelWidth, const DeviceCoordinate* pPixelDXArray, + SalLayoutFlags flags = SalLayoutFlags::NONE, + vcl::TextLayoutCache const* = nullptr) const; + SAL_DLLPRIVATE std::unique_ptr<SalLayout> + ImplGlyphFallbackLayout( std::unique_ptr<SalLayout>, ImplLayoutArgs& ) const; + SAL_DLLPRIVATE std::unique_ptr<SalLayout> + getFallbackLayout( + LogicalFontInstance* pLogicalFont, int nFallbackLevel, + ImplLayoutArgs& rLayoutArgs) const; + + + // Enabling/disabling RTL only makes sense for OutputDevices that use a mirroring SalGraphisLayout + virtual void EnableRTL( bool bEnable = true); + bool IsRTLEnabled() const { return mbEnableRTL; } + + bool GetTextIsRTL( const OUString&, sal_Int32 nIndex, sal_Int32 nLen ) const; + + ///@} + + + /** @name Bitmap functions + */ + ///@{ + +public: + + /** @overload + void DrawBitmap( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSecSizePixel, + const Bitmap& rBitmap, + MetaActionType nAction = MetaActionType::BMPSCALEPART) + */ + void DrawBitmap( + const Point& rDestPt, + const Bitmap& rBitmap ); + + /** @overload + void DrawBitmap( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSecSizePixel, + const Bitmap& rBitmap, + MetaActionType nAction = MetaActionType::BMPSCALEPART) + */ + void DrawBitmap( + const Point& rDestPt, + const Size& rDestSize, + const Bitmap& rBitmap ); + + void DrawBitmap( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSrcSizePixel, + const Bitmap& rBitmap, + MetaActionType nAction = MetaActionType::BMPSCALEPART ); + + /** @overload + void DrawBitmapEx( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSecSizePixel, + const BitmapEx& rBitmapEx, + MetaActionType nAction = MetaActionType::BMPEXSCALEPART) + */ + void DrawBitmapEx( + const Point& rDestPt, + const BitmapEx& rBitmapEx ); + + + /** @overload + void DrawBitmapEx( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSecSizePixel, + const BitmapEx& rBitmapEx, + MetaActionType nAction = MetaActionType::BMPEXSCALEPART) + */ + void DrawBitmapEx( + const Point& rDestPt, + const Size& rDestSize, + const BitmapEx& rBitmapEx ); + + void DrawBitmapEx( + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSrcSizePixel, + const BitmapEx& rBitmapEx, + MetaActionType nAction = MetaActionType::BMPEXSCALEPART ); + + /** @overload + virtual void DrawImage( + const Point& rPos, + const Size& rSize, + const Image& rImage, + sal_uInt16 nStyle = 0) + */ + void DrawImage( + const Point& rPos, + const Image& rImage, + DrawImageFlags nStyle = DrawImageFlags::NONE ); + + void DrawImage( + const Point& rPos, + const Size& rSize, + const Image& rImage, + DrawImageFlags nStyle = DrawImageFlags::NONE ); + + + virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const; + + /** Query extended bitmap (with alpha channel, if available). + */ + BitmapEx GetBitmapEx( const Point& rSrcPt, const Size& rSize ) const; + + + /** Draw BitmapEx transformed + + @param rTransformation + The transformation describing the target positioning of the given bitmap. Transforming + the unit object coordinates (0, 0, 1, 1) with this matrix is the transformation to + discrete coordinates + + @param rBitmapEx + The BitmapEx to be painted + */ + void DrawTransformedBitmapEx( + const basegfx::B2DHomMatrix& rTransformation, + const BitmapEx& rBitmapEx); + + void DrawShadowBitmapEx( + const BitmapEx& rBitmapEx, + ::Color aShadowColor); +protected: + + virtual void DrawDeviceBitmap( + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + BitmapEx& rBitmapEx ); + + virtual void ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry ); + + /** Transform and draw a bitmap directly + + @param aFullTransform The B2DHomMatrix used for the transformation + @param rBitmapEx Reference to the bitmap to be transformed and drawn + + @return true if it was able to draw the bitmap, false if not + */ + virtual bool DrawTransformBitmapExDirect( + const basegfx::B2DHomMatrix& aFullTransform, + const BitmapEx& rBitmapEx); + + /** Transform and reduce the area that needs to be drawn of the bitmap and return the new + visible range and the maximum area. + + + @param aFullTransform B2DHomMatrix used for transformation + @param aVisibleRange The new visible area of the bitmap + @param fMaximumArea The maximum area of the bitmap + + @returns true if there is an area to be drawn, otherwise nothing is left to be drawn + so return false + */ + virtual bool TransformAndReduceBitmapExToTargetRange( + const basegfx::B2DHomMatrix& aFullTransform, + basegfx::B2DRange &aVisibleRange, + double &fMaximumArea); + +private: + + SAL_DLLPRIVATE void DrawDeviceAlphaBitmap( + const Bitmap& rBmp, + const AlphaMask& rAlpha, + const Point& rDestPt, + const Size& rDestSize, + const Point& rSrcPtPixel, + const Size& rSrcSizePixel ); + + SAL_DLLPRIVATE void DrawDeviceAlphaBitmapSlowPath( + const Bitmap& rBitmap, const AlphaMask& rAlpha, + tools::Rectangle aDstRect, tools::Rectangle aBmpRect, + Size const & aOutSz, Point const & aOutPt); + + + SAL_DLLPRIVATE void BlendBitmap( + const SalTwoRect& rPosAry, + const Bitmap& rBmp ); + + SAL_DLLPRIVATE Bitmap BlendBitmap( + Bitmap& aBmp, + BitmapReadAccess const * pP, + BitmapReadAccess const * pA, + const sal_Int32 nOffY, + const sal_Int32 nDstHeight, + const sal_Int32 nOffX, + const sal_Int32 nDstWidth, + const tools::Rectangle& aBmpRect, + const Size& aOutSz, + const bool bHMirr, + const bool bVMirr, + const long* pMapX, + const long* pMapY ); + + SAL_DLLPRIVATE Bitmap BlendBitmapWithAlpha( + Bitmap& aBmp, + BitmapReadAccess const * pP, + BitmapReadAccess const * pA, + const tools::Rectangle& aDstRect, + const sal_Int32 nOffY, + const sal_Int32 nDstHeight, + const sal_Int32 nOffX, + const sal_Int32 nDstWidth, + const long* pMapX, + const long* pMapY ); + + /** Retrieve downsampled and cropped bitmap + + @attention This method ignores negative rDstSz values, thus + mirroring must happen outside this method (e.g. in DrawBitmap) + */ + SAL_DLLPRIVATE Bitmap GetDownsampledBitmap( + const Size& rDstSz, + const Point& rSrcPt, + const Size& rSrcSz, + const Bitmap& rBmp, + long nMaxBmpDPIX, + long nMaxBmpDPIY ); + + ///@} + + + /** @name Transparency functions + */ + ///@{ + +public: + + /** helper method removing transparencies from a metafile (e.g. for printing) + + @returns + true: transparencies were removed + false: output metafile is unchanged input metafile + + @attention this is a member method, so current state can influence the result ! + @attention the output metafile is prepared in pixel mode for the currentOutputDevice + state. It can not be moved or rotated reliably anymore. + */ + bool RemoveTransparenciesFromMetaFile( + const GDIMetaFile& rInMtf, GDIMetaFile& rOutMtf, + long nMaxBmpDPIX, long nMaxBmpDPIY, + bool bReduceTransparency, + bool bTransparencyAutoMode, + bool bDownsampleBitmaps, + const Color& rBackground = COL_TRANSPARENT ); + + SAL_DLLPRIVATE void ImplPrintTransparent ( + const Bitmap& rBmp, const Bitmap& rMask, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ); + + SAL_DLLPRIVATE Color ImplDrawModeToColor ( const Color& rColor ) const; + + + void DrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ); + + void DrawTransparent( + const basegfx::B2DHomMatrix& rObjectTransform, + const basegfx::B2DPolyPolygon& rB2DPolyPoly, + double fTransparency); + + void DrawTransparent( + const GDIMetaFile& rMtf, const Point& rPos, const Size& rSize, + const Gradient& rTransparenceGradient ); + +protected: + + virtual void EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ); + void DrawInvisiblePolygon( const tools::PolyPolygon& rPolyPoly ); + + virtual void ClipAndDrawGradientMetafile ( const Gradient &rGradient, const tools::PolyPolygon &rPolyPoly ); + +private: + + SAL_DLLPRIVATE bool DrawTransparentNatively( const tools::PolyPolygon& rPolyPoly, sal_uInt16 nTransparencePercent ); + ///@} + + + /** @name Mask functions + */ + ///@{ + +public: + + void DrawMask( const Point& rDestPt, + const Bitmap& rBitmap, const Color& rMaskColor ); + + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap, const Color& rMaskColor ); + + void DrawMask( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + const Bitmap& rBitmap, const Color& rMaskColor, + MetaActionType nAction ); + +protected: + + virtual void DrawDeviceMask ( + const Bitmap& rMask, const Color& rMaskColor, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ); + ///@} + + + /** @name Map functions + */ + ///@{ + +public: + + void EnableMapMode( bool bEnable = true ); + bool IsMapModeEnabled() const { return mbMap; } + + void SetMapMode(); + virtual void SetMapMode( const MapMode& rNewMapMode ); + void SetRelativeMapMode( const MapMode& rNewMapMode ); + const MapMode& GetMapMode() const { return maMapMode; } + +protected: + virtual void ImplInitMapModeObjects(); + +public: + // #i75163# + basegfx::B2DHomMatrix GetViewTransformation() const; + basegfx::B2DHomMatrix GetInverseViewTransformation() const; + + basegfx::B2DHomMatrix GetViewTransformation( const MapMode& rMapMode ) const; + basegfx::B2DHomMatrix GetInverseViewTransformation( const MapMode& rMapMode ) const; + + + /** Set an offset in pixel + + This method offsets every drawing operation that converts its + coordinates to pixel by the given value. Normally, the effect + can be achieved by setting a MapMode with a different + origin. Unfortunately, this origin is in logical coordinates + and can lead to rounding errors (see #102532# for details). + + @attention This offset is only applied when converting to + pixel, i.e. some output modes such as metafile recordings + might be completely unaffected by this method! Use with + care. Furthermore, if the OutputDevice's MapMode is the + default (that's MapUnit::MapPixel), then any pixel offset set is + ignored also. This might be unintuitive for cases, but would + have been far more fragile to implement. What's more, the + reason why the pixel offset was introduced (avoiding rounding + errors) does not apply for MapUnit::MapPixel, because one can always + use the MapMode origin then. + + @param rOffset + The offset in pixel + */ + void SetPixelOffset( const Size& rOffset ); + + /** Get the offset in pixel + + @see OutputDevice::SetPixelOffset for details + + @return the current offset in pixel + */ + Size GetPixelOffset() const { return Size(mnOutOffOrigX, mnOutOffOrigY);} + + Point LogicToPixel( const Point& rLogicPt ) const; + Size LogicToPixel( const Size& rLogicSize ) const; + tools::Rectangle LogicToPixel( const tools::Rectangle& rLogicRect ) const; + tools::Polygon LogicToPixel( const tools::Polygon& rLogicPoly ) const; + tools::PolyPolygon LogicToPixel( const tools::PolyPolygon& rLogicPolyPoly ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly ) const; + vcl::Region LogicToPixel( const vcl::Region& rLogicRegion )const; + Point LogicToPixel( const Point& rLogicPt, + const MapMode& rMapMode ) const; + Size LogicToPixel( const Size& rLogicSize, + const MapMode& rMapMode ) const; + tools::Rectangle LogicToPixel( const tools::Rectangle& rLogicRect, + const MapMode& rMapMode ) const; + tools::Polygon LogicToPixel( const tools::Polygon& rLogicPoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon LogicToPixel( const basegfx::B2DPolyPolygon& rLogicPolyPoly, + const MapMode& rMapMode ) const; + + Point PixelToLogic( const Point& rDevicePt ) const; + Size PixelToLogic( const Size& rDeviceSize ) const; + tools::Rectangle PixelToLogic( const tools::Rectangle& rDeviceRect ) const; + tools::Polygon PixelToLogic( const tools::Polygon& rDevicePoly ) const; + tools::PolyPolygon PixelToLogic( const tools::PolyPolygon& rDevicePolyPoly ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly ) const; + vcl::Region PixelToLogic( const vcl::Region& rDeviceRegion ) const; + Point PixelToLogic( const Point& rDevicePt, + const MapMode& rMapMode ) const; + Size PixelToLogic( const Size& rDeviceSize, + const MapMode& rMapMode ) const; + tools::Rectangle PixelToLogic( const tools::Rectangle& rDeviceRect, + const MapMode& rMapMode ) const; + tools::Polygon PixelToLogic( const tools::Polygon& rDevicePoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolygon PixelToLogic( const basegfx::B2DPolygon& rDevicePoly, + const MapMode& rMapMode ) const; + basegfx::B2DPolyPolygon PixelToLogic( const basegfx::B2DPolyPolygon& rDevicePolyPoly, + const MapMode& rMapMode ) const; + + Point LogicToLogic( const Point& rPtSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + Size LogicToLogic( const Size& rSzSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + tools::Rectangle LogicToLogic( const tools::Rectangle& rRectSource, + const MapMode* pMapModeSource, + const MapMode* pMapModeDest ) const; + static Point LogicToLogic( const Point& rPtSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static Size LogicToLogic( const Size& rSzSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static tools::Rectangle LogicToLogic( const tools::Rectangle& rRectSource, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + static long LogicToLogic( long nLongSource, + MapUnit eUnitSource, + MapUnit eUnitDest ); + + static basegfx::B2DPolygon LogicToLogic( const basegfx::B2DPolygon& rPoly, + const MapMode& rMapModeSource, + const MapMode& rMapModeDest ); + + // create a mapping transformation from rMapModeSource to rMapModeDest (the above methods + // for B2DPoly/Polygons use this internally anyway to transform the B2DPolygon) + static basegfx::B2DHomMatrix LogicToLogic(const MapMode& rMapModeSource, const MapMode& rMapModeDest); + + /** Convert a logical rectangle to a rectangle in physical device pixel units. + + @param rLogicRect Const reference to a rectangle in logical units + + @returns Rectangle based on physical device pixel coordinates and units. + */ + SAL_DLLPRIVATE tools::Rectangle ImplLogicToDevicePixel( const tools::Rectangle& rLogicRect ) const; + + /** Convert a logical point to a physical point on the device. + + @param rLogicPt Const reference to a point in logical units. + + @returns Physical point on the device. + */ + SAL_DLLPRIVATE Point ImplLogicToDevicePixel( const Point& rLogicPt ) const; + + /** Convert a logical width to a width in units of device pixels. + + To get the number of device pixels, it must calculate the X-DPI of the device and + the map scaling factor. If there is no mapping, then it just returns the + width as nothing more needs to be done. + + @param nWidth Logical width + + @returns Width in units of device pixels. + */ + SAL_DLLPRIVATE long ImplLogicWidthToDevicePixel( long nWidth ) const; + + SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( long nWidth ) const; + + /** Convert a logical X coordinate to a device pixel's X coordinate. + + To get the device's X coordinate, it must calculate the mapping offset + coordinate X position (if there is one - if not then it just adds + the pseudo-window offset to the logical X coordinate), the X-DPI of + the device and the mapping's X scaling factor. + + @param nX Logical X coordinate + + @returns Device's X pixel coordinate + */ + SAL_DLLPRIVATE long ImplLogicXToDevicePixel( long nX ) const; + + /** Convert a logical Y coordinate to a device pixel's Y coordinate. + + To get the device's Y coordinate, it must calculate the mapping offset + coordinate Y position (if there is one - if not then it just adds + the pseudo-window offset to the logical Y coordinate), the Y-DPI of + the device and the mapping's Y scaling factor. + + @param nY Logical Y coordinate + + @returns Device's Y pixel coordinate + */ + SAL_DLLPRIVATE long ImplLogicYToDevicePixel( long nY ) const; + + /** Convert a logical height to a height in units of device pixels. + + To get the number of device pixels, it must calculate the Y-DPI of the device and + the map scaling factor. If there is no mapping, then it just returns the + height as nothing more needs to be done. + + @param nHeight Logical height + + @returns Height in units of device pixels. + */ + SAL_DLLPRIVATE long ImplLogicHeightToDevicePixel( long nHeight ) const; + + /** Convert device pixels to a width in logical units. + + To get the logical width, it must calculate the X-DPI of the device and the + map scaling factor. + + @param nWidth Width in device pixels + + @returns Width in logical units. + */ + SAL_DLLPRIVATE long ImplDevicePixelToLogicWidth( long nWidth ) const; + + /** Convert device pixels to a height in logical units. + + To get the logical height, it must calculate the Y-DPI of the device and the + map scaling factor. + + @param nHeight Height in device pixels + + @returns Height in logical units. + */ + SAL_DLLPRIVATE long ImplDevicePixelToLogicHeight( long nHeight ) const; + + /** Convert logical height to device pixels, with exact sub-pixel value. + + To get the \em exact pixel height, it must calculate the Y-DPI of the device and the + map scaling factor. + + @param fLogicHeight Exact height in logical units. + + @returns Exact height in pixels - returns as a float to provide for subpixel value. + */ + SAL_DLLPRIVATE float ImplFloatLogicHeightToDevicePixel( float fLogicHeight ) const; + + /** Convert a logical size to the size on the physical device. + + @param rLogicSize Const reference to a size in logical units + + @returns Physical size on the device. + */ + SAL_DLLPRIVATE Size ImplLogicToDevicePixel( const Size& rLogicSize ) const; + + /** Convert a rectangle in physical pixel units to a rectangle in physical pixel units and coords. + + @param rPixelRect Const reference to rectangle in logical units and coords. + + @returns Rectangle based on logical coordinates and units. + */ + SAL_DLLPRIVATE tools::Rectangle ImplDevicePixelToLogic( const tools::Rectangle& rPixelRect ) const; + + /** Convert a logical polygon to a polygon in physical device pixel units. + + @param rLogicPoly Const reference to a polygon in logical units + + @returns Polygon based on physical device pixel coordinates and units. + */ + SAL_DLLPRIVATE tools::Polygon ImplLogicToDevicePixel( const tools::Polygon& rLogicPoly ) const; + + /** Convert a logical polypolygon to a polypolygon in physical device pixel units. + + @param rLogicPolyPoly Const reference to a polypolygon in logical units + + @returns Polypolygon based on physical device pixel coordinates and units. + */ + SAL_DLLPRIVATE tools::PolyPolygon ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const; + + /** Convert a line in logical units to a line in physical device pixel units. + + @param rLineInfo Const reference to a line in logical units + + @returns Line based on physical device pixel coordinates and units. + */ + SAL_DLLPRIVATE LineInfo ImplLogicToDevicePixel( const LineInfo& rLineInfo ) const; + + /** Convert a region in pixel units to a region in device pixel units and coords. + + @param rRegion Const reference to region. + + @returns vcl::Region based on device pixel coordinates and units. + */ + SAL_DLLPRIVATE vcl::Region ImplPixelToDevicePixel( const vcl::Region& rRegion ) const; + + /** Invalidate the view transformation. + + @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212) + */ + SAL_DLLPRIVATE void ImplInvalidateViewTransform(); + + /** Get device transformation. + + @since AOO bug 75163 (OpenOffice.org 2.4.3 - OOH 680 milestone 212) + */ + SAL_DLLPRIVATE basegfx::B2DHomMatrix ImplGetDeviceTransformation() const; + ///@} + + + /** @name Native Widget Rendering functions + + These all just call through to the private mpGraphics functions of the same name. + */ + ///@{ + +public: + + /** Query the platform layer for control support + */ + bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) const; + + /** Query the native control to determine if it was acted upon + */ + bool HitTestNativeScrollbar( + ControlPart nPart, + const tools::Rectangle& rControlRegion, + const Point& aPos, + bool& rIsInside ) const; + + /** Request rendering of a particular control and/or part + */ + bool DrawNativeControl( + ControlType nType, + ControlPart nPart, + const tools::Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const OUString& aCaption, + const Color& rBackgroundColor = COL_AUTO ); + + /** Query the native control's actual drawing region (including adornment) + */ + bool GetNativeControlRegion( + ControlType nType, + ControlPart nPart, + const tools::Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + tools::Rectangle &rNativeBoundingRegion, + tools::Rectangle &rNativeContentRegion ) const; + ///@} + + /** @name EPS functions + */ + ///@{ + +public: + + /** @returns boolean value to see if EPS could be painted directly. + Theoretically, handing over a matrix would be needed to handle + painting rotated EPS files (e.g. contained in Metafiles). This + would then need to be supported for Mac and PS printers, but + that's too much for now, wrote \#i107046# for this */ + bool DrawEPS( + const Point& rPt, const Size& rSz, + const GfxLink& rGfxLink, GDIMetaFile* pSubst = nullptr ); + ///@} +}; + +#endif // INCLUDED_VCL_OUTDEV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdev/ScopedStates.hxx b/include/vcl/outdev/ScopedStates.hxx new file mode 100644 index 000000000..b64167587 --- /dev/null +++ b/include/vcl/outdev/ScopedStates.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SCOPEDSTATES_HXX +#define INCLUDED_VCL_SCOPEDSTATES_HXX + +#include <vcl/outdev.hxx> + +namespace vcl +{ +class ScopedAntialiasing +{ +private: + OutputDevice& m_rOutputDevice; + AntialiasingFlags m_nPreviousAAState; + +public: + ScopedAntialiasing(OutputDevice& rOutputDevice, bool bAAState) + : m_rOutputDevice(rOutputDevice) + , m_nPreviousAAState(m_rOutputDevice.GetAntialiasing()) + { + if (bAAState) + rOutputDevice.SetAntialiasing(m_nPreviousAAState | AntialiasingFlags::EnableB2dDraw); + else + rOutputDevice.SetAntialiasing(m_nPreviousAAState & ~AntialiasingFlags::EnableB2dDraw); + } + + ~ScopedAntialiasing() { m_rOutputDevice.SetAntialiasing(m_nPreviousAAState); } +}; +} + +#endif // INCLUDED_VCL_SCOPEDSTATES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdevmap.hxx b/include/vcl/outdevmap.hxx new file mode 100644 index 000000000..c6494f065 --- /dev/null +++ b/include/vcl/outdevmap.hxx @@ -0,0 +1,43 @@ +/* -*- 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_OUTDEVMAP_HXX +#define INCLUDED_VCL_OUTDEVMAP_HXX + +struct ImplMapRes +{ + long mnMapOfsX; // Offset in X direction + long mnMapOfsY; // Offset in Y direction + long mnMapScNumX; // Scaling factor - numerator in X direction + long mnMapScNumY; // Scaling factor - numerator in Y direction + long mnMapScDenomX; // Scaling factor - denominator in X direction + long mnMapScDenomY; // Scaling factor - denominator in Y direction +}; + +struct ImplThresholdRes +{ + long mnThresLogToPixX; // Thresholds for calculation + long mnThresLogToPixY; // with BigInts + long mnThresPixToLogX; // "" + long mnThresPixToLogY; // "" +}; + +#endif // INCLUDED_VCL_OUTDEVMAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx new file mode 100644 index 000000000..62a4af7fb --- /dev/null +++ b/include/vcl/outdevstate.hxx @@ -0,0 +1,104 @@ +/* -*- 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_OUTDEVSTATE_HXX +#define INCLUDED_VCL_OUTDEVSTATE_HXX + +#include <vcl/mapmod.hxx> +#include <vcl/vclenum.hxx> + +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <tools/fontenum.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <memory> +#include <optional> +#include <i18nlangtag/lang.h> + +namespace vcl { class Font; } +namespace vcl { class Region; } + +// Flags for OutputDevice::Push() and OutDevState +enum class PushFlags { + NONE = 0x0000, + LINECOLOR = 0x0001, + FILLCOLOR = 0x0002, + FONT = 0x0004, + TEXTCOLOR = 0x0008, + MAPMODE = 0x0010, + CLIPREGION = 0x0020, + RASTEROP = 0x0040, + TEXTFILLCOLOR = 0x0080, + TEXTALIGN = 0x0100, + REFPOINT = 0x0200, + TEXTLINECOLOR = 0x0400, + TEXTLAYOUTMODE = 0x0800, + TEXTLANGUAGE = 0x1000, + OVERLINECOLOR = 0x2000, + ALL = 0xFFFF +}; + +namespace o3tl +{ + template<> struct typed_flags<PushFlags> : is_typed_flags<PushFlags, 0xFFFF> {}; +} +#define PUSH_ALLTEXT (PushFlags::TEXTCOLOR | PushFlags::TEXTFILLCOLOR | PushFlags::TEXTLINECOLOR | PushFlags::OVERLINECOLOR | PushFlags::TEXTALIGN | PushFlags::TEXTLAYOUTMODE | PushFlags::TEXTLANGUAGE) +#define PUSH_ALLFONT (PUSH_ALLTEXT | PushFlags::FONT) + +// Layout flags for Complex Text Layout +// These are flag values, i.e they can be combined +enum class ComplexTextLayoutFlags +{ + Default = 0x0000, + BiDiRtl = 0x0001, + BiDiStrong = 0x0002, + TextOriginLeft = 0x0004, + TextOriginRight = 0x0008 +}; +namespace o3tl { + template<> struct typed_flags<ComplexTextLayoutFlags> : is_typed_flags<ComplexTextLayoutFlags, 0x000f> {}; +} + +struct OutDevState +{ + OutDevState(); + OutDevState(OutDevState&&); + ~OutDevState(); + + std::optional<MapMode> mpMapMode; + bool mbMapActive; + std::unique_ptr<vcl::Region> mpClipRegion; + std::optional<Color> mpLineColor; + std::optional<Color> mpFillColor; + std::unique_ptr<vcl::Font> mpFont; + std::optional<Color> mpTextColor; + std::optional<Color> mpTextFillColor; + std::optional<Color> mpTextLineColor; + std::optional<Color> mpOverlineColor; + std::optional<Point> mpRefPoint; + TextAlign meTextAlign; + RasterOp meRasterOp; + ComplexTextLayoutFlags mnTextLayoutMode; + LanguageType meTextLanguage; + PushFlags mnFlags; +}; + +#endif // INCLUDED_VCL_OUTDEVSTATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx new file mode 100644 index 000000000..ea5466b86 --- /dev/null +++ b/include/vcl/pdfextoutdevdata.hxx @@ -0,0 +1,486 @@ +/* -*- 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_PDFEXTOUTDEVDATA_HXX +#define INCLUDED_VCL_PDFEXTOUTDEVDATA_HXX + +#include <vcl/dllapi.h> + +#include <vcl/pdfwriter.hxx> +#include <vcl/extoutdevdata.hxx> +#include <vector> +#include <memory> + +class Graphic; +class GDIMetaFile; + +namespace vcl +{ + +/* + A PDFExtOutDevBookmarkEntry is being created by the EditEngine if + a bookmark URL has been parsed. The Application is requested to take + care of each bookmark entry by emptying out the bookmark vector. +*/ +struct PDFExtOutDevBookmarkEntry +{ + /** ID of the link pointing to the bookmark, or -1 if the entry denotes a destination instead of a link. + */ + sal_Int32 nLinkId; + + /** ID of the named destination denoted by the bookmark, or -1 if the entry denotes a link instead of a named destination. + */ + sal_Int32 nDestId; + + /** link target name, respectively destination name + */ + OUString aBookmark; + + PDFExtOutDevBookmarkEntry() + :nLinkId( -1 ) + ,nDestId( -1 ) + ,aBookmark() + { + } +}; + +/* + Class that is being set at the OutputDevice allowing the + application to send enhanced PDF commands like CreateLink +*/ +struct PageSyncData; +struct GlobalSyncData; +class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData +{ + + const OutputDevice& mrOutDev; + + bool mbTaggedPDF; + bool mbExportNotes; + bool mbExportNotesPages; + bool mbTransitionEffects; + bool mbUseLosslessCompression; + bool mbReduceImageResolution; + bool mbExportFormFields; + bool mbExportBookmarks; + bool mbExportHiddenSlides; + bool mbSinglePageSheets; + bool mbExportNDests; //i56629 + sal_Int32 mnPage; + sal_Int32 mnCompressionQuality; + css::lang::Locale maDocLocale; + + std::unique_ptr<PageSyncData> mpPageSyncData; + std::unique_ptr<GlobalSyncData> mpGlobalSyncData; + + std::vector< PDFExtOutDevBookmarkEntry > maBookmarks; + std::vector<OUString> maChapterNames; + +public: + + PDFExtOutDevData( const OutputDevice& rOutDev ); + virtual ~PDFExtOutDevData() override; + + bool PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAction, const GDIMetaFile& rMtf ); + void ResetSyncData(); + + void PlayGlobalActions( PDFWriter& rWriter ); + + bool GetIsExportNotes() const { return mbExportNotes;} + void SetIsExportNotes( const bool bExportNotes ); + + bool GetIsExportNotesPages() const { return mbExportNotesPages;} + void SetIsExportNotesPages( const bool bExportNotesPages ); + + bool GetIsExportTaggedPDF() const { return mbTaggedPDF;} + void SetIsExportTaggedPDF( const bool bTaggedPDF ); + + bool GetIsExportTransitionEffects() const { return mbTransitionEffects;} + void SetIsExportTransitionEffects( const bool bTransitionalEffects ); + + bool GetIsExportFormFields() const { return mbExportFormFields;} + void SetIsExportFormFields( const bool bExportFormFields ); + + bool GetIsExportBookmarks() const { return mbExportBookmarks;} + void SetIsExportBookmarks( const bool bExportBookmarks ); + + bool GetIsExportHiddenSlides() const { return mbExportHiddenSlides;} + void SetIsExportHiddenSlides( const bool bExportHiddenSlides ); + + void SetIsSinglePageSheets( const bool bSinglePageSheets ); + + bool GetIsExportNamedDestinations() const { return mbExportNDests;} //i56629 + void SetIsExportNamedDestinations( const bool bExportNDests ); //i56629 + + // PageNumber, Compression is being set by the PDFExport + sal_Int32 GetCurrentPageNumber() const { return mnPage;} + void SetCurrentPageNumber( const sal_Int32 nPage ); + + bool GetIsLosslessCompression() const { return mbUseLosslessCompression;} + void SetIsLosslessCompression( const bool bLosslessCompression ); + + void SetCompressionQuality( const sal_Int32 nQuality ); + + bool GetIsReduceImageResolution() const { return mbReduceImageResolution;} + void SetIsReduceImageResolution( const bool bReduceImageResolution ); + + const css::lang::Locale& GetDocumentLocale() const { return maDocLocale;} + void SetDocumentLocale( const css::lang::Locale& rLoc ); + + std::vector< PDFExtOutDevBookmarkEntry >& GetBookmarks() { return maBookmarks;} + const std::vector<OUString>& GetChapterNames() const { return maChapterNames; } + + const Graphic& GetCurrentGraphic() const; + + /** Start a new group of render output + + Use this method to group render output. + */ + void BeginGroup(); + + /** End render output + + This method ends grouped render output, that can be + represented by a GfxLink. This is typically used for + external graphic files, such as JPEGs, EPS files etc. + The BeginGroup/EndGroup calls must exactly enclose the + relevant OutputDevice calls issued to render the + graphic the normal way. + + @param rGraphic + The link to the original graphic + + @param nTransparency + Eight bit transparency value, with 0 denoting full opacity, + and 255 full transparency. + + @param rOutputRect + The output rectangle of the graphic. + + @param rVisibleOutputRect + The visible part of the output. This might be less than + rOutputRect, e.g. for cropped graphics. + */ + void EndGroup( const Graphic& rGraphic, + sal_uInt8 nTransparency, + const tools::Rectangle& rOutputRect, + const tools::Rectangle& rVisibleOutputRect ); + + /// Detect if stream is compressed enough to avoid de-compress / scale & re-compress + bool HasAdequateCompression( const Graphic &rGraphic, + const tools::Rectangle &rOutputRect, + const tools::Rectangle &rVisibleOutputRect ) const; + +//--->i56629 + /** Create a new named destination to be used in a link to this document from another PDF document + (see PDF spec 1.4, 8.2.1) + + @param sDestName + the name this destination will be addressed with from others PDF document + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr = -1 ); + + /** registers a destination for which a destination ID needs to be known immediately, instead of later on setting it via + SetLinkDest. + + This is used in contexts where a destination is referenced by means other than a link. + + Later in the export process, a call to DescribeRegisteredDest must be made, providing the information about + the destination. + + @return + the unique Id of the destination + */ + sal_Int32 RegisterDest(); + + /** provides detailed information about a destination range which previously has been registered using RegisterDest. + */ + void DescribeRegisteredDest( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, PDFWriter::DestAreaType eType = PDFWriter::DestAreaType::XYZ ); + +//<---i56629 + + /** Create a new destination to be used in a link + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateDest( const tools::Rectangle& rRect, sal_Int32 nPageNr = -1, PDFWriter::DestAreaType eType = PDFWriter::DestAreaType::XYZ ); + /** Create a new link on a page + + @param rRect + active rectangle of the link (that is the area that has to be + hit to activate the link) + + @param nPageNr + number of page the link is on (as returned by NewPage) + or -1 in which case the current page is used + + @returns + the link id (to be used in SetLinkDest, SetLinkURL) or + -1 if page id does not exist + */ + sal_Int32 CreateLink( const tools::Rectangle& rRect, sal_Int32 nPageNr = -1 ); + + /// Create a Screen annotation. + sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr); + + /** Set the destination for a link + <p>will change a URL type link to a dest link if necessary</p> + + @param nLinkId + the link to be changed + + @param nDestId + the dest the link shall point to + */ + void SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); + /** Set the URL for a link + <p>will change a dest type link to a URL type link if necessary</p> + @param nLinkId + the link to be changed + + @param rURL + the URL the link shall point to. + there will be no error checking or any kind of + conversion done to this parameter execept this: + it will be output as 7bit Ascii. The URL + will appear literally in the PDF file produced + */ + void SetLinkURL( sal_Int32 nLinkId, const OUString& rURL ); + + /// Set URL for a linked Screen annotation. + void SetScreenURL(sal_Int32 nScreenId, const OUString& rURL); + /// Set URL for an embedded Screen annotation. + void SetScreenStream(sal_Int32 nScreenId, const OUString& rURL); + + /** Create a new outline item + + @param nParent + declares the parent of the new item in the outline hierarchy. + An invalid value will result in a new toplevel item. + + @param rText + sets the title text of the item + + @param nDestID + declares which Dest (created with CreateDest) the outline item + will point to + + @returns + the outline item id of the new item + */ + sal_Int32 CreateOutlineItem( sal_Int32 nParent, const OUString& rText, sal_Int32 nDestID ); + + /** Create a new note on a page + + @param rRect + active rectangle of the note (that is the area that has to be + hit to popup the annotation) + + @param rNote + specifies the contents of the note + + @param nPageNr + number of page the note is on (as returned by NewPage) + or -1 in which case the current page is used + */ + void CreateNote( const tools::Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 ); + + /** begin a new logical structure element + + BeginStructureElement/EndStructureElement calls build the logical structure + of the PDF - the basis for tagged PDF. Structural elements are implemented + using marked content tags. Each structural element can contain sub elements + (e.g. a section can contain a heading and a paragraph). The structure hierarchy + is build automatically from the Begin/EndStructureElement calls. + + A structural element need not be contained on one page; e.g. paragraphs often + run from one page to the next. In this case the corresponding EndStructureElement + must be called while drawing the next page. + + BeginStructureElement and EndStructureElement must be called only after + PDFWriter::NewPage has been called and before + PDFWriter::Emit gets called. The current page + number is an implicit context parameter for Begin/EndStructureElement. + + For pagination artifacts that are not part of the logical structure + of the document (like header, footer or page number) the special + StructElement NonStructElement exists. To place content + outside of the structure tree simply call + BeginStructureElement( NonStructElement ) then draw your + content and then call EndStructureElement(). Any children + of a NonStructElement will not be part of the structure as well. + + @param eType + denotes what kind of element to begin (e.g. a heading or paragraph) + + @param rAlias + the specified alias will be used as structure tag. Also an entry in the PDF's + role map will be created mapping alias to regular structure type. + + @returns + the id of the newly created structural element + */ + sal_Int32 BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias = OUString() ); + /** end a logical structure element + + @see BeginStructureElement + */ + void EndStructureElement(); + /** set the current structure element + + <p> + For different purposes it may be useful to paint a structure element's + content discontinuously. In that case an already existing structure element + can be appended to by using SetCurrentStructureElement. The + referenced structure element becomes the current structure element with + all consequences: all following structure elements are appended as children + of the current element. + </p> + + @param nElement + the id of the new current structure element + + @returns + True if the current structure element could be set successfully + False if the current structure element could not be changed + (e.g. if the passed element id is invalid) + */ + bool SetCurrentStructureElement( sal_Int32 nElement ); + /** get the current structure element id + + @returns + the id of the current structure element + */ + sal_Int32 GetCurrentStructureElement() const; + + /** set a structure attribute on the current structural element + + SetStructureAttribute sets an attribute of the current structural element to a + new value. A consistency check is performed before actually setting the value; + if the check fails, the function returns False and the attribute remains + unchanged. + + @param eAttr + denotes what attribute to change + + @param eVal + the value to set the attribute to + */ + void SetStructureAttribute( PDFWriter::StructAttribute eAttr, PDFWriter::StructAttributeValue eVal ); + /** set a structure attribute on the current structural element + + SetStructureAttributeNumerical sets an attribute of the current structural element + to a new numerical value. A consistency check is performed before actually setting + the value; if the check fails, the function returns False and the attribute + remains unchanged. + + @param eAttr + denotes what attribute to change + + @param nValue + the value to set the attribute to + */ + void SetStructureAttributeNumerical( PDFWriter::StructAttribute eAttr, sal_Int32 nValue ); + /** set the bounding box of a structural element + + SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox + attribute can only be applied to Table, Figure, + Form and Formula elements, a call of this function + for other element types will be ignored and the BBox attribute not be set. + + @param rRect + the new bounding box for the structural element + */ + void SetStructureBoundingBox( const tools::Rectangle& rRect ); + + /** set the ActualText attribute of a structural element + + ActualText contains the Unicode text without layout artifacts that is shown by + a structural element. For example if a line is ended prematurely with a break in + a word and continued on the next line (e.g. "happen-<newline>stance") the + corresponding ActualText would contain the unbroken line (e.g. "happenstance"). + + @param rText + contains the complete logical text the structural element displays. + */ + void SetActualText( const OUString& rText ); + + /** set the Alt attribute of a strutural element + + Alt is s replacement text describing the contents of a structural element. This + is mainly used by accessibility applications; e.g. a screen reader would read + the Alt replacement text for an image to a visually impaired user. + + @param rText + contains the replacement text for the structural element + */ + void SetAlternateText( const OUString& rText ); + + /** Sets the transitional effect to be applied when the current page gets shown. + + @param eType + the kind of effect to be used; use Regular to disable transitional effects + for this page + + @param nMilliSec + the duration of the transitional effect in milliseconds; + set 0 to disable transitional effects + */ + void SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec ); + + /** create a new form control + + This function creates a new form control in the PDF and sets its various + properties. Do not pass an actual AnyWidget as rControlType + will be cast to the type described by the type member. + + @param rControlType + a descendant of AnyWidget determining the control's properties + */ + void CreateControl( const PDFWriter::AnyWidget& rControlType ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx new file mode 100644 index 000000000..6896d2e83 --- /dev/null +++ b/include/vcl/pdfread.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SOURCE_FILTER_IPDF_PDFREAD_HXX +#define INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX + +#include <vector> +#include <tools/gen.hxx> +#include <tools/stream.hxx> +#include <basegfx/tuple/b2dtuple.hxx> + +namespace com::sun::star::uno +{ +template <typename> class Sequence; +} +class Bitmap; +class Graphic; + +namespace vcl +{ +/// Fills the rBitmaps vector with rendered pages. +VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, int nSize, std::vector<Bitmap>& rBitmaps, + size_t nFirstPage = 0, int nPages = 1, + const basegfx::B2DTuple* pSizeHint = nullptr); + +/// Imports a PDF stream into rGraphic as VectorGraphicData. +VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic); + +/// Import PDF as Graphic images (1 per page), but not loaded yet. +/// Returns the number of pages read. +VCL_DLLPUBLIC size_t ImportPDFUnloaded(const OUString& rURL, + std::vector<std::pair<Graphic, Size>>& rGraphics); +} + +#endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx new file mode 100644 index 000000000..12f4a8e1e --- /dev/null +++ b/include/vcl/pdfwriter.hxx @@ -0,0 +1,1205 @@ +/* -*- 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_PDFWRITER_HXX +#define INCLUDED_VCL_PDFWRITER_HXX + +#include <config_options.h> +#include <sal/types.h> + +#include <tools/gen.hxx> +#include <tools/color.hxx> +#include <rtl/strbuf.hxx> + +#include <vcl/dllapi.h> +#include <vcl/font.hxx> +#include <vcl/outdev.hxx> +#include <vcl/graph.hxx> + +#include <com/sun/star/lang/Locale.hpp> + +#include <memory> +#include <vector> +#include <set> + +namespace com::sun::star::beans { class XMaterialHolder; } +namespace com::sun::star::io { class XOutputStream; } +namespace com::sun::star::security { class XCertificate; } + +class GDIMetaFile; +class MapMode; +class LineInfo; +namespace tools { + class Polygon; + class PolyPolygon; +} +class Bitmap; +class BitmapEx; +class Gradient; +class Hatch; +class Wallpaper; + +namespace vcl +{ + +class PDFExtOutDevData; +class PDFWriterImpl; + +struct PDFNote +{ + OUString Title; // optional title for the popup containing the note + OUString Contents; // contents of the note +}; + +class VCL_DLLPUBLIC PDFOutputStream +{ + public: + virtual ~PDFOutputStream(); + virtual void write( const css::uno::Reference< css::io::XOutputStream >& xStream ) = 0; +}; + +class VCL_DLLPUBLIC PDFWriter +{ + ScopedVclPtr<PDFWriterImpl> xImplementation; + + PDFWriter(const PDFWriter&) = delete; + PDFWriter& operator=(const PDFWriter&) = delete; + +public: + // extended line info + enum CapType { capButt, capRound, capSquare }; + enum JoinType { joinMiter, joinRound, joinBevel }; + struct ExtLineInfo + { + double m_fLineWidth; + double m_fTransparency; + CapType m_eCap; + JoinType m_eJoin; + double m_fMiterLimit; + std::vector< double > m_aDashArray; + + ExtLineInfo() : m_fLineWidth( 0.0 ), + m_fTransparency( 0.0 ), + m_eCap( capButt ), + m_eJoin( joinMiter ), + m_fMiterLimit( 10.0 ) + {} + }; + + enum class Orientation { Portrait, Inherit }; + + // in case the below enum is added PDF_1_6 PDF_1_7, please add them just after PDF_1_5 + enum class PDFVersion { PDF_1_2, PDF_1_3, PDF_1_4, PDF_1_5, PDF_1_6, PDF_A_1, PDF_A_2, PDF_A_3 };//i59651, PDF/A-1b & -1a, only -1b implemented for now + // for the meaning of DestAreaType please look at PDF Reference Manual + // version 1.4 section 8.2.1, page 475 + enum class DestAreaType { XYZ, FitRectangle }; + + // for a definition of structural element types please refer to + // PDF Reference, 3rd ed. section 9.7.4 + enum StructElement + { + // special element to place outside the structure hierarchy + NonStructElement, + // Grouping elements + Document, Part, Article, Section, Division, BlockQuote, + Caption, TOC, TOCI, Index, + + // block level elements + Paragraph, Heading, H1, H2, H3, H4, H5, H6, + List, ListItem, LILabel, LIBody, + Table, TableRow, TableHeader, TableData, + + // inline level elements + Span, Quote, Note, Reference, BibEntry, Code, Link, + + // illustration elements + Figure, Formula, Form + }; + + enum StructAttribute + { + Placement, WritingMode, SpaceBefore, SpaceAfter, StartIndent, EndIndent, + TextIndent, TextAlign, Width, Height, BlockAlign, InlineAlign, + LineHeight, BaselineShift, TextDecorationType, ListNumbering, + RowSpan, ColSpan, + + // link destination is an artificial attribute that sets + // the link annotation ID of a Link element + // further note: since structure attributes can only be + // set during content creation, but links can be + // created after the fact, it is possible to set + // an arbitrary id as structure attribute here. In this + // case the arbitrary id has to be passed again when the + // actual link annotation is created via SetLinkPropertyID + LinkAnnotation, + // Language currently sets a LanguageType (see i18nlangtag/lang.h) + // which will be internally changed to a corresponding locale + Language + }; + + enum StructAttributeValue + { + Invalid, + NONE, + // Placement + Block, Inline, Before, After, Start, End, + // WritingMode + LrTb, RlTb, TbRl, + // TextAlign + Center, Justify, + // Width, Height, + Auto, + // BlockAlign + Middle, + // LineHeight + Normal, + // TextDecorationType + Underline, Overline, LineThrough, + // ListNumbering + Disc, Circle, Square, Decimal, UpperRoman, LowerRoman, UpperAlpha, LowerAlpha + }; + + enum class PageTransition + { + Regular, + SplitHorizontalInward, SplitHorizontalOutward, + SplitVerticalInward, SplitVerticalOutward, + BlindsHorizontal, BlindsVertical, + BoxInward, BoxOutward, + WipeLeftToRight, WipeBottomToTop, WipeRightToLeft, WipeTopToBottom, + Dissolve + }; + + enum WidgetType + { + PushButton, RadioButton, CheckBox, Edit, ListBox, ComboBox, Hierarchy, + Signature + }; + + enum ErrorCode + { + // transparent object occurred and was draw opaque because + // PDF/A does not allow transparency + Warning_Transparency_Omitted_PDFA, + + // transparent object occurred but is only supported since + // PDF 1.4 + Warning_Transparency_Omitted_PDF13, + + // a form action was exported that is not suitable for PDF/A + // the action was skipped + Warning_FormAction_Omitted_PDFA, + + // transparent objects were converted to a bitmap in order + // to removetransparencies from the output + Warning_Transparency_Converted, + + // signature generation failed + Error_Signature_Failed, + }; + + struct UNLESS_MERGELIBS(VCL_DLLPUBLIC) AnyWidget + { + WidgetType Type; // primitive RTTI + public: + OUString Name; // a distinct name to identify the control + OUString Description;// descriptive text for the control (e.g. for tool tip) + OUString Text; // user text to appear on the control + DrawTextFlags TextStyle; // style flags + bool ReadOnly; + tools::Rectangle Location; // describes the area filled by the control + bool Border; // true: widget should have a border, false: no border + Color BorderColor;// COL_TRANSPARENT and Border=true means get color from application settings + bool Background; // true: widget shall draw its background, false: no background + Color BackgroundColor; // COL_TRANSPARENT and Background=true means get color from application settings + vcl::Font TextFont; // an empty font will be replaced by the + // appropriate font from the user settings + Color TextColor; // COL_TRANSPARENT will be replaced by the appropriate color from application settings + sal_Int32 TabOrder; // lowest number is first in tab order + + /* style flags for text are those for OutputDevice::DrawText + allowed values are: + DrawTextFlags::Left, DrawTextFlags::Center, DrawTextFlags::Right, DrawTextFlags::Top, + DrawTextFlags::VCenter, DrawTextFlags::Bottom, + DrawTextFlags::MultiLine, DrawTextFlags::WordBreak + + if TextStyle is 0, then each control will fill in default values + */ + + // note: the Name member comprises the field name of the resulting + // PDF field names need to be globally unique. Therefore if any + // Widget with an already used name is created, the name will be + // made unique by adding an underscore ('_') and an ascending number + // to the name. + + AnyWidget( WidgetType eType ) : + Type( eType ), + TextStyle( DrawTextFlags::NONE ), + ReadOnly( false ), + Border( false ), + BorderColor( COL_TRANSPARENT ), + Background( false ), + BackgroundColor( COL_TRANSPARENT ), + TextColor( COL_TRANSPARENT ), + TabOrder( -1 ) + {} + virtual ~AnyWidget(); + + WidgetType getType() const { return Type; } + + virtual std::shared_ptr<AnyWidget> Clone() const = 0; + + protected: + // note that this equals the default compiler-generated copy-ctor, but we want to have it + // protected, to only allow sub classes to access it + AnyWidget( const AnyWidget& rSource ) + :Type( rSource.Type ) + ,Name( rSource.Name ) + ,Description( rSource.Description ) + ,Text( rSource.Text ) + ,TextStyle( rSource.TextStyle ) + ,ReadOnly( rSource.ReadOnly ) + ,Location( rSource.Location ) + ,Border( rSource.Border ) + ,BorderColor( rSource.BorderColor ) + ,Background( rSource.Background ) + ,BackgroundColor( rSource.BackgroundColor ) + ,TextFont( rSource.TextFont ) + ,TextColor( rSource.TextColor ) + ,TabOrder( rSource.TabOrder ) + { + } + AnyWidget& operator=( const AnyWidget& ); // never implemented + }; + + struct PushButtonWidget final : public AnyWidget + { + /* If Dest is set to a valid link destination, + Then pressing the button will act as a goto + action within the document. + + Else: + An empty URL means this button will reset the form. + + If URL is not empty and Submit is set, then the URL + contained will be set as the URL to submit the + form to. In this case the submit method will be + either GET if SubmitGet is true or POST if + SubmitGet is false. + + If URL is not empty and Submit is clear, then + the URL contained will be interpreted as a + hyperlink to be executed on pushing the button. + + There will be no error checking or any kind of + conversion done to the URL parameter execept this: + it will be output as 7bit Ascii. The URL + will appear literally in the PDF file produced + */ + sal_Int32 Dest; + OUString URL; + bool Submit; + bool SubmitGet; + + PushButtonWidget() + : AnyWidget( vcl::PDFWriter::PushButton ), + Dest( -1 ), Submit( false ), SubmitGet( false ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<PushButtonWidget>( *this ); + } + }; + + struct CheckBoxWidget final : public AnyWidget + { + bool Checked; + + CheckBoxWidget() + : AnyWidget( vcl::PDFWriter::CheckBox ), + Checked( false ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<CheckBoxWidget>( *this ); + } + }; + + struct RadioButtonWidget final : public AnyWidget + { + bool Selected; + sal_Int32 RadioGroup; + OUString OnValue; // the value of the radio button if it is selected + + RadioButtonWidget() + : AnyWidget( vcl::PDFWriter::RadioButton ), + Selected( false ), + RadioGroup( 0 ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<RadioButtonWidget>( *this ); + } + // radio buttons having the same RadioGroup id comprise one + // logical radio button group, that is at most one of the RadioButtons + // in a group can be checked at any time + // + // note: a PDF radio button field consists of a named field + // containing unnamed checkbox child fields. The name of the + // radio button field is taken from the first RadioButtonWidget created + // in the group + }; + + struct EditWidget final : public AnyWidget + { + bool MultiLine; // whether multiple lines are allowed + bool Password; // visible echo off + bool FileSelect; // field is a file selector + sal_Int32 MaxLen; // maximum field length in characters, 0 means unlimited + + EditWidget() + : AnyWidget( vcl::PDFWriter::Edit ), + MultiLine( false ), + Password( false ), + FileSelect( false ), + MaxLen( 0 ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<EditWidget>( *this ); + } + }; + + struct ListBoxWidget final : public AnyWidget + { + bool DropDown; + bool MultiSelect; + std::vector<OUString> Entries; + std::vector<sal_Int32> SelectedEntries; + // if MultiSelect is false only the first entry of SelectedEntries + // will be taken into account. the same is implicit for PDF < 1.4 + // since multiselect is a 1.4+ feature + + ListBoxWidget() + : AnyWidget( vcl::PDFWriter::ListBox ), + DropDown( false ), + MultiSelect( false ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<ListBoxWidget>( *this ); + } + }; + + // note: PDF only supports dropdown comboboxes + struct ComboBoxWidget final : public AnyWidget + { + std::vector<OUString> Entries; + // set the current value in AnyWidget::Text + + ComboBoxWidget() + : AnyWidget( vcl::PDFWriter::ComboBox ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<ComboBoxWidget>( *this ); + } + }; + + struct SignatureWidget final : public AnyWidget + { + SignatureWidget() + : AnyWidget( vcl::PDFWriter::Signature ) + {} + + virtual std::shared_ptr<AnyWidget> Clone() const override + { + return std::make_shared<SignatureWidget>( *this ); + } + }; + + enum ExportDataFormat { HTML, XML, FDF, PDF }; +// see 3.6.1 of PDF 1.4 ref for details, used for 8.1 PDF v 1.4 ref also +// These emuns are treated as integer while reading/writing to configuration + enum PDFViewerPageMode + { + ModeDefault, + UseOutlines, + UseThumbs + }; +// These emuns are treated as integer while reading/writing to configuration + enum PDFViewerAction + { + ActionDefault, + FitInWindow, + FitWidth, + FitVisible, + ActionZoom + }; +// These enums are treated as integer while reading/writing to configuration + enum PDFPageLayout + { + DefaultLayout, + SinglePage, + Continuous, + ContinuousFacing + }; + + // These emuns are treated as integer while reading/writing to configuration + //what default action to generate in a PDF hyperlink to external document/site + enum PDFLinkDefaultAction + { + URIAction, + URIActionDestination, + LaunchAction + }; + +/* +The following structure describes the permissions used in PDF security + */ + struct PDFEncryptionProperties + { + + //for both 40 and 128 bit security, see 3.5.2 PDF v 1.4 table 3.15, v 1.5 and v 1.6 table 3.20. + bool CanPrintTheDocument; + bool CanModifyTheContent; + bool CanCopyOrExtract; + bool CanAddOrModify; + //for revision 3 (bit 128 security) only + bool CanFillInteractive; + bool CanExtractForAccessibility; + bool CanAssemble; + bool CanPrintFull; + + // encryption will only happen if EncryptionKey is not empty + // EncryptionKey is actually a construct out of OValue, UValue and DocumentIdentifier + // if these do not match, behavior is undefined, most likely an invalid PDF will be produced + // OValue, UValue, EncryptionKey and DocumentIdentifier can be computed from + // PDFDocInfo, Owner password and User password used the InitEncryption method which + // implements the algorithms described in the PDF reference chapter 3.5: Encryption + std::vector<sal_uInt8> OValue; + std::vector<sal_uInt8> UValue; + std::vector<sal_uInt8> EncryptionKey; + std::vector<sal_uInt8> DocumentIdentifier; + + //permission default set for 128 bit, accessibility only + PDFEncryptionProperties() : + CanPrintTheDocument ( false ), + CanModifyTheContent ( false ), + CanCopyOrExtract ( false ), + CanAddOrModify ( false ), + CanFillInteractive ( false ), + CanExtractForAccessibility ( true ), + CanAssemble ( false ), + CanPrintFull ( false ) + {} + + + bool Encrypt() const + { return ! OValue.empty() && ! UValue.empty() && ! DocumentIdentifier.empty(); } + }; + + struct PDFDocInfo + { + OUString Title; // document title + OUString Author; // document author + OUString Subject; // subject + OUString Keywords; // keywords + OUString Creator; // application that created the original document + OUString Producer; // OpenOffice + }; + + enum ColorMode + { + DrawColor, DrawGreyscale + }; + + struct PDFWriterContext + { + /* must be a valid file: URL usable by osl */ + OUString URL; + /* the URL of the document being exported, used for relative links*/ + OUString BaseURL; + /*if relative to file system should be formed*/ + bool RelFsys;//i56629, i49415?, i64585? + /*the action to set the PDF hyperlink to*/ + PDFWriter::PDFLinkDefaultAction DefaultLinkAction; + //convert the .od? target file type in a link to a .pdf type + //this is examined before doing anything else + bool ConvertOOoTargetToPDFTarget; + //when the file type is .pdf, force the GoToR action + bool ForcePDFAction; + + /* decides the PDF language level to be produced */ + PDFVersion Version; + + /* PDF/UA compliance */ + bool UniversalAccessibilityCompliance; + + /* valid for PDF >= 1.4 + causes the MarkInfo entry in the document catalog to be set + */ + bool Tagged; + /* determines in which format a form + will be submitted. + */ + PDFWriter::ExportDataFormat SubmitFormat; + bool AllowDuplicateFieldNames; + /* the following data members are used to customize the PDF viewer + preferences + */ + /* see 3.6.1 PDF v 1.4 ref*/ + PDFWriter::PDFViewerPageMode PDFDocumentMode; + PDFWriter::PDFViewerAction PDFDocumentAction; + // in percent, valid only if PDFDocumentAction == ActionZoom + sal_Int32 Zoom; + + /* see 8.6 PDF v 1.4 ref + specifies whether to hide the viewer tool + bars when the document is active. + */ + bool HideViewerToolbar; + bool HideViewerMenubar; + bool HideViewerWindowControls; + bool FitWindow; + bool OpenInFullScreenMode; + bool CenterWindow; + bool DisplayPDFDocumentTitle; + PDFPageLayout PageLayout; + bool FirstPageLeft; + // initially visible page in viewer (starting with 0 for first page) + sal_Int32 InitialPage; + sal_Int32 OpenBookmarkLevels; // -1 means all levels + + PDFWriter::PDFEncryptionProperties Encryption; + PDFWriter::PDFDocInfo DocumentInfo; + + bool SignPDF; + OUString SignLocation; + OUString SignPassword; + OUString SignReason; + OUString SignContact; + css::lang::Locale DocumentLocale; // defines the document default language + sal_uInt32 DPIx, DPIy; // how to handle MapMode( MapUnit::MapPixel ) + // 0 here specifies a default handling + PDFWriter::ColorMode ColorMode; + css::uno::Reference< css::security::XCertificate> SignCertificate; + OUString SignTSA; + /// Use reference XObject markup for PDF images. + bool UseReferenceXObject; + + PDFWriterContext() : + RelFsys( false ), //i56629, i49415?, i64585? + DefaultLinkAction( PDFWriter::URIAction ), + ConvertOOoTargetToPDFTarget( false ), + ForcePDFAction( false ), + Version( PDFWriter::PDFVersion::PDF_1_6 ), + UniversalAccessibilityCompliance( false ), + Tagged( false ), + SubmitFormat( PDFWriter::FDF ), + AllowDuplicateFieldNames( false ), + PDFDocumentMode( PDFWriter::ModeDefault ), + PDFDocumentAction( PDFWriter::ActionDefault ), + Zoom( 100 ), + HideViewerToolbar( false ), + HideViewerMenubar( false ), + HideViewerWindowControls( false ), + FitWindow( false ), + OpenInFullScreenMode( false ), + CenterWindow( false ), + DisplayPDFDocumentTitle( true ), + PageLayout( PDFWriter::DefaultLayout ), + FirstPageLeft( false ), + InitialPage( 1 ), + OpenBookmarkLevels( -1 ), + Encryption(), + SignPDF( false ), + DPIx( 0 ), + DPIy( 0 ), + ColorMode( PDFWriter::DrawColor ), + UseReferenceXObject( false ) + {} + }; + + PDFWriter( const PDFWriterContext& rContext, const css::uno::Reference< css::beans::XMaterialHolder >& ); + ~PDFWriter(); + + /** Returns an OutputDevice for formatting + This Output device is guaranteed to use the same + font metrics as the resulting PDF file. + + @returns + the reference output device + */ + OutputDevice* GetReferenceDevice(); + + /** Creates a new page to fill + If width and height are not set the page size + is inherited from the page tree + other effects: + resets the graphics state: MapMode, Font + Colors and other state information MUST + be set again or are undefined. + */ + void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Orientation::Inherit ); + /** Play a metafile like an outputdevice would do + */ + struct PlayMetafileContext + { + int m_nMaxImageResolution; + bool m_bOnlyLosslessCompression; + int m_nJPEGQuality; + bool m_bTransparenciesWereRemoved; + + PlayMetafileContext() + : m_nMaxImageResolution( 0 ) + , m_bOnlyLosslessCompression( false ) + , m_nJPEGQuality( 90 ) + , m_bTransparenciesWereRemoved( false ) + {} + + }; + void PlayMetafile( const GDIMetaFile&, const PlayMetafileContext&, vcl::PDFExtOutDevData* pDevDat = nullptr ); + + /* sets the document locale originally passed with the context to a new value + * only affects the output if used before calling Emit. + */ + void SetDocumentLocale( const css::lang::Locale& rDocLocale ); + + /* finishes the file */ + bool Emit(); + + /* + * Get a list of errors that occurred during processing + * this should enable the producer to give feedback about + * any anomalies that might have occurred + */ + std::set< ErrorCode > const & GetErrors() const; + + // uses 128bit encryption + static css::uno::Reference< css::beans::XMaterialHolder > + InitEncryption( const OUString& i_rOwnerPassword, + const OUString& i_rUserPassword + ); + + /* functions for graphics state */ + /* flag values: see vcl/outdev.hxx */ + void Push( PushFlags nFlags = PushFlags::ALL ); + void Pop(); + + void SetClipRegion(); + void SetClipRegion( const basegfx::B2DPolyPolygon& rRegion ); + void MoveClipRegion( long nHorzMove, long nVertMove ); + void IntersectClipRegion( const tools::Rectangle& rRect ); + void IntersectClipRegion( const basegfx::B2DPolyPolygon& rRegion ); + + void SetLayoutMode( ComplexTextLayoutFlags nMode ); + void SetDigitLanguage( LanguageType eLang ); + + void SetLineColor( const Color& rColor ); + void SetLineColor() { SetLineColor( COL_TRANSPARENT ); } + + void SetFillColor( const Color& rColor ); + void SetFillColor() { SetFillColor( COL_TRANSPARENT ); } + + void SetFont( const vcl::Font& rNewFont ); + void SetTextColor( const Color& rColor ); + void SetTextFillColor(); + void SetTextFillColor( const Color& rColor ); + + void SetTextLineColor(); + void SetTextLineColor( const Color& rColor ); + void SetOverlineColor(); + void SetOverlineColor( const Color& rColor ); + void SetTextAlign( ::TextAlign eAlign ); + + void SetMapMode( const MapMode& rNewMapMode ); + + + /* actual drawing functions */ + void DrawText( const Point& rPos, const OUString& rText ); + + void DrawTextLine( const Point& rPos, long nWidth, + FontStrikeout eStrikeout, + FontLineStyle eUnderline, + FontLineStyle eOverline ); + void DrawTextArray( const Point& rStartPt, const OUString& rStr, + const long* pDXAry, + sal_Int32 nIndex, + sal_Int32 nLen ); + void DrawStretchText( const Point& rStartPt, sal_uLong nWidth, + const OUString& rStr, + sal_Int32 nIndex, sal_Int32 nLen ); + void DrawText( const tools::Rectangle& rRect, + const OUString& rStr, DrawTextFlags nStyle ); + + void DrawPixel( const Point& rPt, const Color& rColor ); + void DrawPixel( const Point& rPt ) + { DrawPixel( rPt, COL_TRANSPARENT ); } + + void DrawLine( const Point& rStartPt, const Point& rEndPt ); + void DrawLine( const Point& rStartPt, const Point& rEndPt, + const LineInfo& rLineInfo ); + void DrawPolyLine( const tools::Polygon& rPoly ); + void DrawPolyLine( const tools::Polygon& rPoly, + const LineInfo& rLineInfo ); + void DrawPolyLine( const tools::Polygon& rPoly, const ExtLineInfo& rInfo ); + void DrawPolygon( const tools::Polygon& rPoly ); + void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly ); + void DrawRect( const tools::Rectangle& rRect ); + void DrawRect( const tools::Rectangle& rRect, + sal_uLong nHorzRount, sal_uLong nVertRound ); + void DrawEllipse( const tools::Rectangle& rRect ); + void DrawArc( const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawPie( const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + void DrawChord( const tools::Rectangle& rRect, + const Point& rStartPt, const Point& rEndPt ); + + void DrawBitmap( const Point& rDestPt, const Size& rDestSize, + const Bitmap& rBitmap, const Graphic& rGraphic ); + + void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, + const BitmapEx& rBitmapEx ); + + void DrawGradient( const tools::Rectangle& rRect, const Gradient& rGradient ); + void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); + + void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ); + + void DrawWallpaper( const tools::Rectangle& rRect, const Wallpaper& rWallpaper ); + void DrawTransparent( const tools::PolyPolygon& rPolyPoly, + sal_uInt16 nTransparencePercent ); + + /** Start a transparency group + + Drawing operations can be grouped together to acquire a common transparency + behaviour; after calling BeginTransparencyGroup all drawing + operations will be grouped together into a transparent object. + + The transparency behaviour is set with one of the EndTransparencyGroup + calls and can be either a constant transparency factor or a transparent + soft mask in form of an 8 bit gray scale bitmap. + + It is permissible to nest transparency group. + + Transparency groups MUST NOT span multiple pages + + Transparency is a feature introduced in PDF1.4, so transparency group + will be ignored if the produced PDF has a lower version. The drawing + operations will be emitted normally. + */ + void BeginTransparencyGroup(); + + /** End a transparency group with constant transparency factor + + This ends a transparency group and inserts it on the current page. The + coordinates of the group result out of the grouped drawing operations. + + @param rBoundRect + The bounding rectangle of the group + + @param nTransparencePercent + The transparency factor + */ + void EndTransparencyGroup( const tools::Rectangle& rBoundRect, sal_uInt16 nTransparencePercent ); + + /** Insert a JPG encoded image (optionally with mask) + + @param rJPGData + a Stream containing the encoded image + + @param bIsTrueColor + true: jpeg is 24 bit true color, false: jpeg is 8 bit greyscale + + @param rSrcSizePixel + size in pixel of the image + + @param rTargetArea + where to put the image + + @param rMask + optional mask; if not empty it must have + the same pixel size as the image and + be either 1 bit black&white or 8 bit grey + */ + void DrawJPGBitmap( SvStream& rJPGData, bool bIsTrueColor, const Size& rSrcSizePixel, const tools::Rectangle& rTargetArea, const Bitmap& rMask, const Graphic& rGraphic ); + + /** Create a new named destination to be used in a link from another PDF document + + @param sDestName + the name (label) of the bookmark, to be used to jump to + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateNamedDest( const OUString& sDestName, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ); + /** Create a new destination to be used in a link + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the destination id (to be used in SetLinkDest) or + -1 if page id does not exist + */ + sal_Int32 CreateDest( const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ); + /** Create a new link on a page + + @param rRect + active rectangle of the link (that is the area that has to be + hit to activate the link) + + @param nPageNr + number of page the link is on (as returned by NewPage) + or -1 in which case the current page is used + + @returns + the link id (to be used in SetLinkDest, SetLinkURL) or + -1 if page id does not exist + */ + sal_Int32 CreateLink( const tools::Rectangle& rRect, sal_Int32 nPageNr ); + + /// Creates a screen annotation. + sal_Int32 CreateScreen(const tools::Rectangle& rRect, sal_Int32 nPageNr); + + /** creates a destination which is not intended to be referred to by a link, but by a public destination Id. + + Form widgets, for instance, might refer to a destination, without ever actually creating a source link to + point to this destination. In such cases, a public destination Id will be assigned to the form widget, + and later on, the concrete destination data for this public Id will be registered using RegisterDestReference. + + @param nDestId + destination ID + + @param rRect + target rectangle on page to be displayed if dest is jumped to + + @param nPageNr + number of page the dest is on (as returned by NewPage) + or -1 in which case the current page is used + + @param eType + what dest type to use + + @returns + the internal destination Id. + */ + sal_Int32 RegisterDestReference( sal_Int32 nDestId, const tools::Rectangle& rRect, sal_Int32 nPageNr, DestAreaType eType ); + + + /** Set the destination for a link + will change a URL type link to a dest link if necessary + + @param nLinkId + the link to be changed + + @param nDestId + the dest the link shall point to + */ + void SetLinkDest( sal_Int32 nLinkId, sal_Int32 nDestId ); + /** Set the URL for a link + will change a dest type link to a URL type link if necessary + @param nLinkId + the link to be changed + + @param rURL + the URL the link shall point to. + The URL will be parsed (and corrected) by the com.sun.star.util.URLTransformer + service; the result will then appear literally in the PDF file produced + */ + void SetLinkURL( sal_Int32 nLinkId, const OUString& rURL ); + + /// Sets the URL of a linked screen annotation. + void SetScreenURL(sal_Int32 nScreenId, const OUString& rURL); + /// Sets the URL of an embedded screen annotation. + void SetScreenStream(sal_Int32 nScreenId, const OUString& rURL); + + /** Resolve link in logical structure + + If a link is created after the corresponding visual appearance was drawn + it is not possible to set the link id as a property attribute to the + link structure item that should be created in tagged PDF around the + visual appearance of a link. + + For this reason an arbitrary id can be given to + SetStructureAttributeNumerical at the time the text for + the link is drawn. To resolve this arbitrary id again when the actual + link annotation is created use SetLinkPropertyID. When Emit + finally gets called all LinkAnnotation type structure attributes + will be replaced with the correct link id. + + CAUTION: this technique must be used either for all or none of the links + in a document since the link id space and arbitrary property id space + could overlap and it would be impossible to resolve whether a Link + structure attribute value was arbitrary or already a real id. + + @param nLinkId + the link to be mapped + + @param nPropertyID + the arbitrary id set in a Link structure element to address + the link with real id nLinkId + */ + void SetLinkPropertyID( sal_Int32 nLinkId, sal_Int32 nPropertyID ); + /** Create a new outline item + + @param nParent + declares the parent of the new item in the outline hierarchy. + An invalid value will result in a new toplevel item. + + @param rText + sets the title text of the item + + @param nDestID + declares which Dest (created with CreateDest) the outline item + will point to + + @returns + the outline item id of the new item + */ + sal_Int32 CreateOutlineItem( sal_Int32 nParent, const OUString& rText, sal_Int32 nDestID ); + + /** Create a new note on a page + + @param rRect + active rectangle of the note (that is the area that has to be + hit to popup the annotation) + + @param rNote + specifies the contents of the note + + @param nPageNr + number of page the note is on (as returned by NewPage) + or -1 in which case the current page is used + */ + void CreateNote( const tools::Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr ); + + /** begin a new logical structure element + + BeginStructureElement/EndStructureElement calls build the logical structure + of the PDF - the basis for tagged PDF. Structural elements are implemented + using marked content tags. Each structural element can contain sub elements + (e.g. a section can contain a heading and a paragraph). The structure hierarchy + is build automatically from the Begin/EndStructureElement calls. + + A structural element need not be contained on one page; e.g. paragraphs often + run from one page to the next. In this case the corresponding EndStructureElement + must be called while drawing the next page. + + BeginStructureElement and EndStructureElement must be called only after + PDFWriter::NewPage has been called and before PDFWriter::Emit gets called. The + current page number is an implicit context parameter for Begin/EndStructureElement. + + For pagination artifacts that are not part of the logical structure + of the document (like header, footer or page number) the special + StructElement NonStructElement exists. To place content + outside of the structure tree simply call + BeginStructureElement( NonStructElement ) then draw your + content and then call EndStructureElement(). All children + of a NonStructElement will not be part of the structure. + Nonetheless if you add a child structural element to a + NonStructElement you will still have to call + EndStructureElement for it. Best think of the structure + tree as a stack. + + Note: there is always one structural element in existence without having + called BeginStructureElement; this is the root of the structure + tree (called StructTreeRoot). The StructTreeRoot has always the id 0. + + @param eType + denotes what kind of element to begin (e.g. a heading or paragraph) + + @param rAlias + the specified alias will be used as structure tag. Also an entry in the PDF's + role map will be created mapping alias to regular structure type. + + @returns + the new structure element's id for use in SetCurrentStructureElement + */ + sal_Int32 BeginStructureElement( enum StructElement eType, const OUString& rAlias ); + /** end the current logical structure element + + Close the current structure element. The current element's + parent becomes the current structure element again. + + @see BeginStructureElement + */ + void EndStructureElement(); + /** set the current structure element + + For different purposes it may be useful to paint a structure element's + content discontinuously. In that case an already existing structure element + can be appended to by using SetCurrentStructureElement. The + referenced structure element becomes the current structure element with + all consequences: all following structure elements are appended as children + of the current element. + + @param nElement + the id of the new current structure element + */ + void SetCurrentStructureElement( sal_Int32 nElement ); + + /** set a structure attribute on the current structural element + + SetStructureAttribute sets an attribute of the current structural element to a + new value. A consistency check is performed before actually setting the value; + if the check fails, the function returns False and the attribute remains + unchanged. + + @param eAttr + denotes what attribute to change + + @param eVal + the value to set the attribute to + */ + void SetStructureAttribute( enum StructAttribute eAttr, enum StructAttributeValue eVal ); + /** set a structure attribute on the current structural element + + SetStructureAttributeNumerical sets an attribute of the current structural element + to a new numerical value. A consistency check is performed before actually setting + the value; if the check fails, the function returns False and the attribute + remains unchanged. + + @param eAttr + denotes what attribute to change + + @param nValue + the value to set the attribute to + */ + void SetStructureAttributeNumerical( enum StructAttribute eAttr, sal_Int32 nValue ); + /** set the bounding box of a structural element + + SetStructureBoundingBox sets the BBox attribute to a new value. Since the BBox + attribute can only be applied to Table, Figure, + Form and Formula elements, a call of this function + for other element types will be ignored and the BBox attribute not be set. + + @param rRect + the new bounding box for the structural element + */ + void SetStructureBoundingBox( const tools::Rectangle& rRect ); + + /** set the ActualText attribute of a structural element + + ActualText contains the Unicode text without layout artifacts that is shown by + a structural element. For example if a line is ended prematurely with a break in + a word and continued on the next line (e.g. "happen-<newline>stance") the + corresponding ActualText would contain the unbroken line (e.g. "happenstance"). + + @param rText + contains the complete logical text the structural element displays. + */ + void SetActualText( const OUString& rText ); + + /** set the Alt attribute of a strutural element + + Alt is s replacement text describing the contents of a structural element. This + is mainly used by accessibility applications; e.g. a screen reader would read + the Alt replacement text for an image to a visually impaired user. + + @param rText + contains the replacement text for the structural element + */ + void SetAlternateText( const OUString& rText ); + + /** Sets the transitional effect to be applied when the current page gets shown. + + @param eType + the kind of effect to be used; use Regular to disable transitional effects + for this page + + @param nMilliSec + the duration of the transitional effect in milliseconds; + set 0 to disable transitional effects + + @param nPageNr + the page number to apply the effect to; -1 denotes the current page + */ + void SetPageTransition( PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr ); + + /** create a new form control + + This function creates a new form control in the PDF and sets its various + properties. Do not pass an actual AnyWidget as rControlType + will be cast to the type described by the type member. + + @param rControlType + a descendant of AnyWidget determining the control's properties + + @returns + the new control's id for reference purposes + */ + sal_Int32 CreateControl( const AnyWidget& rControlType ); + + /** Inserts an additional stream to the PDF file + + This function adds an arbitrary stream to the produced PDF file. May be called + any time before Emit(). The stream will be written during + Emit by calling the PDFOutputStream Object's write + method. After the call the PDFOutputStream will be deleted. + + All additional streams and their mimetypes will be entered into an array + in the trailer dictionary. + + @param rMimeType + the mimetype of the stream + + @param pStream + the interface to the additional stream + + */ + void AddStream( const OUString& rMimeType, PDFOutputStream* pStream ); + + /// Write rString as a PDF hex string into rBuffer. + static void AppendUnicodeTextString(const OUString& rString, OStringBuffer& rBuffer); + + /// Get current date/time in PDF D:YYYYMMDDHHMMSS form. + static OString GetDateTime(); +}; + +} + +#endif // INCLUDED_VCL_PDFWRITER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pngread.hxx b/include/vcl/pngread.hxx new file mode 100644 index 000000000..0fda677e2 --- /dev/null +++ b/include/vcl/pngread.hxx @@ -0,0 +1,63 @@ +/* -*- 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_PNGREAD_HXX +#define INCLUDED_VCL_PNGREAD_HXX + +#include <vcl/dllapi.h> +#include <vcl/bitmapex.hxx> +#include <memory> +#include <vector> + +namespace vcl +{ + +class PNGReaderImpl; + +class VCL_DLLPUBLIC PNGReader +{ + std::unique_ptr<PNGReaderImpl> mpImpl; + +public: + + /* the PNG chunks are read within the c'tor, so the stream will + be positioned at the end of the PNG */ + explicit PNGReader(SvStream& rStream); + ~PNGReader(); + + /* an empty preview size hint (=default) will read the whole image + */ + BitmapEx Read(); + + // retrieve every chunk that resides inside the PNG + struct ChunkData + { + sal_uInt32 nType = 0; + std::vector<sal_uInt8> aData; + }; + const std::vector<ChunkData>& GetChunks() const; + + void SetIgnoreGammaChunk(bool bIgnoreGammaChunk); +}; + +} // end namespace vcl + +#endif // INCLUDED_VCL_PNGREAD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/pngwrite.hxx b/include/vcl/pngwrite.hxx new file mode 100644 index 000000000..de2b1c6e1 --- /dev/null +++ b/include/vcl/pngwrite.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_PNGWRITE_HXX +#define INCLUDED_VCL_PNGWRITE_HXX + +#include <vcl/dllapi.h> +#include <memory> +#include <vector> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class BitmapEx; +class SvStream; + +namespace vcl +{ + class PNGWriterImpl; + + class VCL_DLLPUBLIC PNGWriter + { + const std::unique_ptr<PNGWriterImpl> mpImpl; + + public: + + explicit PNGWriter(const BitmapEx&, const css::uno::Sequence<css::beans::PropertyValue>* pFilterData = nullptr); + ~PNGWriter(); + + bool Write(SvStream& rStream); + + // additional method to be able to modify all chunk before they are stored + struct ChunkData + { + sal_uInt32 nType; + std::vector<sal_uInt8> aData; + }; + std::vector<vcl::PNGWriter::ChunkData>& GetChunks(); + }; +} + +#endif // INCLUDED_VCL_PNGWRITE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/popupmenuwindow.hxx b/include/vcl/popupmenuwindow.hxx new file mode 100644 index 000000000..42488c2ee --- /dev/null +++ b/include/vcl/popupmenuwindow.hxx @@ -0,0 +1,46 @@ +/* -*- 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_POPUPMENUWINDOW_HXX +#define INCLUDED_VCL_POPUPMENUWINDOW_HXX + +#include <vcl/floatwin.hxx> +#include <memory> + +class VCL_DLLPUBLIC PopupMenuFloatingWindow : public FloatingWindow +{ +private: + struct SAL_DLLPRIVATE ImplData; + std::unique_ptr<ImplData> mpImplData; +public: + PopupMenuFloatingWindow( vcl::Window* pParent ); + virtual ~PopupMenuFloatingWindow() override; + virtual void dispose() override; + + sal_uInt16 GetMenuStackLevel() const; + void SetMenuStackLevel( sal_uInt16 nLevel ); + bool IsPopupMenu() const; + + //determine if a given window is an activated PopupMenuFloatingWindow + static bool isPopupMenu(const vcl::Window *pWindow); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx new file mode 100644 index 000000000..5ce81b9a9 --- /dev/null +++ b/include/vcl/print.hxx @@ -0,0 +1,696 @@ +/* -*- 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_PRINT_HXX +#define INCLUDED_VCL_PRINT_HXX + +#include <config_options.h> +#include <rtl/ustring.hxx> +#include <i18nutil/paper.hxx> + +#include <vcl/errcode.hxx> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <vcl/prntypes.hxx> +#include <vcl/jobset.hxx> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/view/PrintableState.hpp> + +#include <memory> +#include <unordered_map> + +class GDIMetaFile; +class SalInfoPrinter; +struct SalPrinterQueueInfo; +class SalPrinter; +class VirtualDevice; +enum class SalPrinterError; + +namespace vcl { + class PrinterController; + class Window; +} + +namespace weld { class Window; } + +enum class PrinterSupport +{ + SetOrientation, + SetPaperSize, SetPaper, + CollateCopy, + SetupDialog +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) QueueInfo +{ + friend class Printer; + +private: + OUString maPrinterName; + OUString maDriver; + OUString maLocation; + OUString maComment; + PrintQueueFlags mnStatus; + sal_uInt32 mnJobs; + +public: + QueueInfo(); + + const OUString& GetPrinterName() const { return maPrinterName; } + const OUString& GetDriver() const { return maDriver; } + const OUString& GetLocation() const { return maLocation; } + const OUString& GetComment() const { return maComment; } + PrintQueueFlags GetStatus() const { return mnStatus; } + sal_uInt32 GetJobs() const { return mnJobs; } +}; + + +enum class PrinterTransparencyMode +{ + Auto = 0, + NONE = 1 +}; + + +enum class PrinterGradientMode +{ + Stripes = 0, + Color = 1 +}; + + +enum class PrinterBitmapMode +{ + Optimal = 0, + Normal = 1, + Resolution = 2 +}; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) PrinterOptions +{ +private: + + bool mbReduceTransparency; + PrinterTransparencyMode meReducedTransparencyMode; + bool mbReduceGradients; + PrinterGradientMode meReducedGradientsMode; + sal_uInt16 mnReducedGradientStepCount; + bool mbReduceBitmaps; + PrinterBitmapMode meReducedBitmapMode; + sal_uInt16 mnReducedBitmapResolution; + bool mbReducedBitmapsIncludeTransparency; + bool mbConvertToGreyscales; + bool mbPDFAsStandardPrintJobFormat; + +public: + PrinterOptions(); + + bool IsReduceTransparency() const { return mbReduceTransparency; } + void SetReduceTransparency( bool bSet ) { mbReduceTransparency = bSet; } + + PrinterTransparencyMode GetReducedTransparencyMode() const { return meReducedTransparencyMode; } + void SetReducedTransparencyMode( PrinterTransparencyMode eMode ) + { meReducedTransparencyMode = eMode; } + + bool IsReduceGradients() const { return mbReduceGradients; } + void SetReduceGradients( bool bSet ) { mbReduceGradients = bSet; } + + PrinterGradientMode GetReducedGradientMode() const { return meReducedGradientsMode; } + void SetReducedGradientMode( PrinterGradientMode eMode ) { meReducedGradientsMode = eMode; } + + sal_uInt16 GetReducedGradientStepCount() const { return mnReducedGradientStepCount; } + void SetReducedGradientStepCount( sal_uInt16 nStepCount ) + { mnReducedGradientStepCount = nStepCount; } + + bool IsReduceBitmaps() const { return mbReduceBitmaps; } + void SetReduceBitmaps( bool bSet ) { mbReduceBitmaps = bSet; } + + PrinterBitmapMode GetReducedBitmapMode() const { return meReducedBitmapMode; } + void SetReducedBitmapMode( PrinterBitmapMode eMode ) { meReducedBitmapMode = eMode; } + + sal_uInt16 GetReducedBitmapResolution() const { return mnReducedBitmapResolution; } + void SetReducedBitmapResolution( sal_uInt16 nResolution ) + { mnReducedBitmapResolution = nResolution; } + + bool IsReducedBitmapIncludesTransparency() const { return mbReducedBitmapsIncludeTransparency; } + void SetReducedBitmapIncludesTransparency( bool bSet ) + { mbReducedBitmapsIncludeTransparency = bSet; } + + bool IsConvertToGreyscales() const { return mbConvertToGreyscales; } + void SetConvertToGreyscales( bool bSet ) { mbConvertToGreyscales = bSet; } + + bool IsPDFAsStandardPrintJobFormat() const { return mbPDFAsStandardPrintJobFormat; } + void SetPDFAsStandardPrintJobFormat( bool bSet ) { mbPDFAsStandardPrintJobFormat = bSet; } + + /** Read printer options from configuration + + parameter decides whether the set for + print "to printer" or "to file" should be read. + */ + void ReadFromConfig( bool bFile ); +}; + + +class VCL_DLLPUBLIC Printer : public OutputDevice +{ + friend class ::OutputDevice; + +private: + SalInfoPrinter* mpInfoPrinter; + std::unique_ptr<SalPrinter> mpPrinter; + SalGraphics* mpJobGraphics; + VclPtr<Printer> mpPrev; + VclPtr<Printer> mpNext; + VclPtr<VirtualDevice> mpDisplayDev; + std::unique_ptr<PrinterOptions> mpPrinterOptions; + OUString maPrinterName; + OUString maDriver; + OUString maPrintFile; + JobSetup maJobSetup; + Point maPageOffset; + Size maPaperSize; + ErrCode mnError; + sal_uInt16 mnPageQueueSize; + sal_uInt16 mnCopyCount; + bool mbDefPrinter; + bool mbPrinting; + bool mbJobActive; + bool mbCollateCopy; + bool mbPrintFile; + bool mbInPrintPage; + bool mbNewJobSetup; + + VCL_DLLPRIVATE void ImplInitData(); + VCL_DLLPRIVATE void ImplInit( SalPrinterQueueInfo* pInfo ); + VCL_DLLPRIVATE void ImplInitDisplay(); + VCL_DLLPRIVATE static SalPrinterQueueInfo* + ImplGetQueueInfo( const OUString& rPrinterName, const OUString* pDriver ); + VCL_DLLPRIVATE void ImplUpdatePageData(); + VCL_DLLPRIVATE void ImplUpdateFontList(); + VCL_DLLPRIVATE void ImplFindPaperFormatForUserSize( JobSetup& ); + + VCL_DLLPRIVATE bool StartJob( const OUString& rJobName, std::shared_ptr<vcl::PrinterController> const & ); + + static VCL_DLLPRIVATE ErrCode + ImplSalPrinterErrorCodeToVCL( SalPrinterError nError ); + +private: + VCL_DLLPRIVATE void EndJob(); + Printer( const Printer& rPrinter ) = delete; + Printer& operator =( const Printer& rPrinter ) = delete; + +public: + VCL_DLLPRIVATE void ImplStartPage(); + VCL_DLLPRIVATE void ImplEndPage(); + +protected: + virtual bool AcquireGraphics() const override; + virtual void ReleaseGraphics( bool bRelease = true ) override; + virtual void ImplReleaseFonts() override; + + virtual long GetGradientStepCount( long nMinRect ) override; + virtual bool UsePolyPolygonForComplexGradient() override; + virtual void ClipAndDrawGradientMetafile ( const Gradient &rGradient, + const tools::PolyPolygon &rPolyPoly ) override; + + void ScaleBitmap ( Bitmap&, SalTwoRect& ) override { }; + vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override; + +public: + void DrawGradientEx( OutputDevice* pOut, const tools::Rectangle& rRect, + const Gradient& rGradient ); + virtual Bitmap GetBitmap( const Point& rSrcPt, const Size& rSize ) const override; + + bool IsScreenComp() const override { return false; } + +protected: + virtual void DrawDeviceMask( const Bitmap& rMask, const Color& rMaskColor, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel) override; + + bool DrawTransformBitmapExDirect( const basegfx::B2DHomMatrix& aFullTransform, + const BitmapEx& rBitmapEx) override; + + bool TransformAndReduceBitmapExToTargetRange( const basegfx::B2DHomMatrix& aFullTransform, + basegfx::B2DRange &aVisibleRange, double &fMaximumArea) override; + + void DrawDeviceBitmap( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel, + BitmapEx& rBitmapEx ) override; + + virtual void EmulateDrawTransparent( const tools::PolyPolygon& rPolyPoly, + sal_uInt16 nTransparencePercent ) override; + + virtual void SetFontOrientation( LogicalFontInstance* const pFontInstance ) const override; + +public: + Printer(); + Printer( const JobSetup& rJobSetup ); + Printer( const QueueInfo& rQueueInfo ); + Printer( const OUString& rPrinterName ); + virtual ~Printer() override; + virtual void dispose() override; + + static const std::vector< OUString >& + GetPrinterQueues(); + static const QueueInfo* GetQueueInfo( const OUString& rPrinterName, bool bStatusUpdate ); + static OUString GetDefaultPrinterName(); + + const OUString& GetName() const { return maPrinterName; } + const OUString& GetDriverName() const { return maDriver; } + bool IsDefPrinter() const { return mbDefPrinter; } + bool IsDisplayPrinter() const { return mpDisplayDev != nullptr; } + bool IsValid() const { return !IsDisplayPrinter(); } + + sal_uInt32 GetCapabilities( PrinterCapType nType ) const; + bool HasSupport( PrinterSupport eFeature ) const; + + bool SetJobSetup( const JobSetup& rSetup ); + const JobSetup& GetJobSetup() const { return maJobSetup; } + + bool Setup(weld::Window* pWindow, + PrinterSetupMode eMode = PrinterSetupMode::DocumentGlobal); + bool SetPrinterProps( const Printer* pPrinter ); + + Color GetBackgroundColor() const override { return COL_WHITE; } + Color GetReadableFontColor(const Color&, const Color&) const override { return COL_BLACK; } + + /** SetPrinterOptions is used internally only now + + in earlier times it was used only to set the options loaded directly from the configuration + in SfxPrinter::InitJob, this is now handled internally + should the need arise to set the printer options outside vcl, also a method would have to be devised + to not override these again internally + */ + VCL_DLLPRIVATE void SetPrinterOptions( const PrinterOptions& rOptions ); + const PrinterOptions& GetPrinterOptions() const { return( *mpPrinterOptions ); } + + bool SetOrientation( Orientation eOrient ); + Orientation GetOrientation() const; + void SetDuplexMode( DuplexMode ); + DuplexMode GetDuplexMode() const; + + bool SetPaperBin( sal_uInt16 nPaperBin ); + sal_uInt16 GetPaperBin() const; + void SetPaper( Paper ePaper ); + bool SetPaperSizeUser( const Size& rSize ); + Paper GetPaper() const; + static OUString GetPaperName( Paper ePaper ); + + /** @return Number of available paper formats */ + int GetPaperInfoCount() const; + + /** @return Info about paper format nPaper */ + const PaperInfo& GetPaperInfo( int nPaper ) const; + sal_uInt16 GetPaperBinCount() const; + OUString GetPaperBinName( sal_uInt16 nPaperBin ) const; + + bool GetPrinterSettingsPreferred() const; + void SetPrinterSettingsPreferred( bool bPaperSizeFromSetup ); + + const Size& GetPaperSizePixel() const { return maPaperSize; } + Size GetPaperSize() const { return PixelToLogic( maPaperSize ); } + Size GetPaperSize( int nPaper ); + const Point& GetPageOffsetPixel() const { return maPageOffset; } + Point GetPageOffset() const { return PixelToLogic( maPageOffset ); } + + void SetCopyCount( sal_uInt16 nCopy, bool bCollate ); + sal_uInt16 GetCopyCount() const { return mnCopyCount; } + bool IsCollateCopy() const { return mbCollateCopy; } + + bool IsPrinting() const { return mbPrinting; } + + bool IsJobActive() const { return mbJobActive; } + + /** Checks the printer list and updates it necessary + + sends a DataChanged event of type DataChangedEventType::PRINTER if the printer list changed + */ + static void updatePrinters(); + + /** Execute a print job + + starts a print job asynchronously that is will return + */ + static void PrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController, + const JobSetup& i_rInitSetup ); + + virtual bool HasMirroredGraphics() const override; + + virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize ) override; + + virtual void DrawOutDev( const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPt, const Size& rSrcSize, + const OutputDevice& rOutDev ) override; + + virtual void CopyArea( const Point& rDestPt, const Point& rSrcPt, + const Size& rSrcSize, bool bWindowInvalidate = false ) override; + + virtual tools::Rectangle GetBackgroundComponentBounds() const override; + + // These 3 together are more modular PrintJob(), allowing printing more documents as one print job + // by repeated calls to ExecutePrintJob(). Used by mailmerge. + static bool PreparePrintJob( std::shared_ptr<vcl::PrinterController> i_pController, + const JobSetup& i_rInitSetup ); + static bool ExecutePrintJob(const std::shared_ptr<vcl::PrinterController>& i_pController); + static void FinishPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController ); + + /** Implementation detail of PrintJob being asynchronous + + not exported, not usable outside vcl + */ + static void VCL_DLLPRIVATE ImplPrintJob( const std::shared_ptr<vcl::PrinterController>& i_pController, + const JobSetup& i_rInitSetup ); +}; + +namespace vcl +{ +class ImplPrinterControllerData; + +enum class NupOrderType +{ + LRTB, TBLR, TBRL, RLTB +}; + +class VCL_DLLPUBLIC PrinterController +{ + std::unique_ptr<ImplPrinterControllerData> + mpImplData; +protected: + PrinterController(const VclPtr<Printer>&, weld::Window*); +public: + struct MultiPageSetup + { + // all metrics in 100th mm + int nRows; + int nColumns; + Size aPaperSize; + long nLeftMargin; + long nTopMargin; + long nRightMargin; + long nBottomMargin; + long nHorizontalSpacing; + long nVerticalSpacing; + bool bDrawBorder; + NupOrderType nOrder; + + MultiPageSetup() + : nRows( 1 ), nColumns( 1 ), aPaperSize( 21000, 29700 ) + , nLeftMargin( 0 ), nTopMargin( 0 ) + , nRightMargin( 0 ), nBottomMargin( 0 ) + , nHorizontalSpacing( 0 ), nVerticalSpacing( 0 ) + , bDrawBorder( false ) + , nOrder( NupOrderType::LRTB ) {} + }; + + struct PageSize + { + /// In 100th mm + Size aSize; + + /// Full paper, not only imageable area is printed + bool bFullPaper; + + PageSize( const Size& i_rSize = Size( 21000, 29700 ), + bool i_bFullPaper = false) + : aSize( i_rSize ), bFullPaper( i_bFullPaper ) {} + }; + + virtual ~PrinterController(); + + const VclPtr<Printer>& getPrinter() const; + weld::Window* getWindow() const; + + /** For implementations: get current job properties as changed by e.g. print dialog + + this gets the current set of properties initially told to Printer::PrintJob + + For convenience a second sequence will be merged in to get a combined sequence. + In case of duplicate property names, the value of i_MergeList wins. + */ + css::uno::Sequence< css::beans::PropertyValue > + getJobProperties(const css::uno::Sequence< css::beans::PropertyValue >& i_rMergeList ) const; + + /// Get the PropertyValue of a Property + css::beans::PropertyValue* getValue( const OUString& i_rPropertyName ); + const css::beans::PropertyValue* getValue( const OUString& i_rPropertyName ) const; + + /** Get a bool property + + in case the property is unknown or not convertible to bool, i_bFallback is returned + */ + bool getBoolProperty( const OUString& i_rPropertyName, bool i_bFallback ) const; + + /** Get an int property + + in case the property is unknown or not convertible to bool, i_nFallback is returned + */ + sal_Int32 getIntProperty( const OUString& i_rPropertyName, sal_Int32 i_nFallback ) const; + + /// Set a property value - can also be used to add another UI property + void setValue( const OUString& i_rPropertyName, const css::uno::Any& i_rValue ); + void setValue( const css::beans::PropertyValue& i_rValue ); + + /** @return The currently active UI options. These are the same that were passed to setUIOptions. */ + const css::uno::Sequence< css::beans::PropertyValue >& + getUIOptions() const; + + /** Set possible UI options. + + should only be done once before passing the PrinterListener to Printer::PrintJob + */ + void setUIOptions( const css::uno::Sequence< css::beans::PropertyValue >& ); + + /// Enable/disable an option; this can be used to implement dialog logic. + bool isUIOptionEnabled( const OUString& rPropName ) const; + bool isUIChoiceEnabled( const OUString& rPropName, sal_Int32 nChoice ) const; + + /** MakeEnabled will change the property rPropName depends on to the value + + that makes rPropName enabled. If the dependency itself is also disabled, + no action will be performed. + + @return The property name rPropName depends on or an empty string if no change was made. + */ + OUString makeEnabled( const OUString& rPropName ); + + /// App must override this + virtual int getPageCount() const = 0; + + /** Get the page parameters + + namely the jobsetup that should be active for the page + (describing among others the physical page size) and the "page size". In writer + case this would probably be the same as the JobSetup since writer sets the page size + draw/impress for example print their page on the paper set on the printer, + possibly adjusting the page size to fit. That means the page size can be different from + the paper size. + + App must override this + + @return Page size in 1/100th mm + */ + virtual css::uno::Sequence< css::beans::PropertyValue > + getPageParameters( int i_nPage ) const = 0; + /// App must override this + virtual void printPage(int i_nPage) const = 0; + + /// Will be called after a possible dialog has been shown and the real printjob starts + virtual void jobStarted(); + virtual void jobFinished( css::view::PrintableState ); + + css::view::PrintableState getJobState() const; + + void abortJob(); + + bool isShowDialogs() const; + bool isDirectPrint() const; + + // implementation details, not usable outside vcl + // don't use outside vcl. Some of these are exported for + // the benefit of vcl's plugins. + // Still: DO NOT USE OUTSIDE VCL + int getFilteredPageCount() const; + VCL_DLLPRIVATE PageSize getPageFile( int i_inUnfilteredPage, GDIMetaFile& rMtf, + bool i_bMayUseCache = false ); + PageSize getFilteredPageFile( int i_nFilteredPage, GDIMetaFile& o_rMtf, + bool i_bMayUseCache = false ); + void printFilteredPage( int i_nPage ); + VCL_DLLPRIVATE void setPrinter( const VclPtr<Printer>& ); + void createProgressDialog(); + bool isProgressCanceled() const; + VCL_DLLPRIVATE void setMultipage( const MultiPageSetup& ); + VCL_DLLPRIVATE const MultiPageSetup& + getMultipage() const; + void setLastPage( bool i_bLastPage ); + VCL_DLLPRIVATE void setReversePrint( bool i_bReverse ); + VCL_DLLPRIVATE void setPapersizeFromSetup( bool i_bPapersizeFromSetup ); + VCL_DLLPRIVATE bool getPapersizeFromSetup() const; + VCL_DLLPRIVATE Size& getPaperSizeSetup() const; + VCL_DLLPRIVATE void setPaperSizeFromUser( Size i_aUserSize ); + VCL_DLLPRIVATE Size& getPaperSizeFromUser() const; + VCL_DLLPRIVATE bool isPaperSizeFromUser() const; + void setPrinterModified( bool i_bPapersizeFromSetup ); + bool getPrinterModified() const; + VCL_DLLPRIVATE void pushPropertiesToPrinter(); + VCL_DLLPRIVATE void resetPaperToLastConfigured(); + void setJobState( css::view::PrintableState ); + VCL_DLLPRIVATE void setupPrinter( weld::Window* i_pDlgParent ); + + VCL_DLLPRIVATE int getPageCountProtected() const; + VCL_DLLPRIVATE css::uno::Sequence< css::beans::PropertyValue > + getPageParametersProtected( int i_nPage ) const; + + VCL_DLLPRIVATE DrawModeFlags removeTransparencies( GDIMetaFile const & i_rIn, GDIMetaFile& o_rOut ); + VCL_DLLPRIVATE void resetPrinterOptions( bool i_bFileOutput ); +}; + +class VCL_DLLPUBLIC PrinterOptionsHelper +{ +protected: + std::unordered_map< OUString, css::uno::Any > + m_aPropertyMap; + std::vector< css::beans::PropertyValue > + m_aUIProperties; + +public: + + /// Create without ui properties + PrinterOptionsHelper() {} + + /** Process a new set of properties + + merges changed properties and returns "true" if any occurred + */ + bool processProperties( const css::uno::Sequence< css::beans::PropertyValue >& i_rNewProp ); + + /** Append to a sequence of property values the ui property sequence passed at creation + + as the "ExtraPrintUIOptions" property. if that sequence was empty, no "ExtraPrintUIOptions" property + will be appended. + */ + void appendPrintUIOptions( css::uno::Sequence< css::beans::PropertyValue >& io_rProps ) const; + + /** @return An empty Any for not existing properties */ + css::uno::Any getValue( const OUString& i_rPropertyName ) const; + + bool getBoolValue( const OUString& i_rPropertyName, bool i_bDefault ) const; + // convenience for fixed strings + bool getBoolValue( const char* i_pPropName, bool i_bDefault = false ) const + { return getBoolValue( OUString::createFromAscii( i_pPropName ), i_bDefault ); } + + sal_Int64 getIntValue( const OUString& i_rPropertyName, sal_Int64 i_nDefault ) const; + // convenience for fixed strings + sal_Int64 getIntValue( const char* i_pPropName, sal_Int64 i_nDefault ) const + { return getIntValue( OUString::createFromAscii( i_pPropName ), i_nDefault ); } + + OUString getStringValue( const OUString& i_rPropertyName ) const; + // convenience for fixed strings + OUString getStringValue( const char* i_pPropName ) const + { return getStringValue( OUString::createFromAscii( i_pPropName ) ); } + + // helper functions for user to create a single control + struct UIControlOptions + { + OUString maDependsOnName; + sal_Int32 mnDependsOnEntry; + bool mbAttachToDependency; + OUString maGroupHint; + bool mbInternalOnly; + bool mbEnabled; + std::vector< css::beans::PropertyValue > + maAddProps; + + UIControlOptions( const OUString& i_rDependsOnName = OUString(), + sal_Int32 i_nDependsOnEntry = -1, bool i_bAttachToDependency = false) + : maDependsOnName( i_rDependsOnName ) + , mnDependsOnEntry( i_nDependsOnEntry ) + , mbAttachToDependency( i_bAttachToDependency ) + , mbInternalOnly( false ) + , mbEnabled( true ) {} + }; + + // note: in the following helper functions HelpIds are expected as an OUString + // the normal HelpId form is OString (byte string instead of UTF16 string) + // this is because the whole interface is base on UNO properties; in fact the structures + // are passed over UNO interfaces. UNO does not know a byte string, hence the string is + // transported via UTF16 strings. + + /// Show general control + static css::uno::Any setUIControlOpt( const css::uno::Sequence< OUString >& i_rIDs, const OUString& i_rTitle, + const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rType, + const css::beans::PropertyValue* i_pValue = nullptr, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + /// Show and set the title of a TagPage of id i_rID + static css::uno::Any setGroupControlOpt( const OUString& i_rID, const OUString& i_rTitle, + const OUString& i_rHelpId); + + /// Show and set the label of a VclFrame of id i_rID + static css::uno::Any setSubgroupControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + /// Show a bool option as a checkbox + static css::uno::Any setBoolControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, + const OUString& i_rProperty, bool i_bValue, + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + /// Show a set of choices in a list box + static css::uno::Any setChoiceListControlOpt( const OUString& i_rID, const OUString& i_rTitle, + const css::uno::Sequence< OUString >& i_rHelpId, const OUString& i_rProperty, + const css::uno::Sequence< OUString >& i_rChoices, sal_Int32 i_nValue, + const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(), + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + /// Show a set of choices as radio buttons + static css::uno::Any setChoiceRadiosControlOpt( const css::uno::Sequence< OUString >& i_rIDs, + const OUString& i_rTitle, const css::uno::Sequence< OUString >& i_rHelpId, + const OUString& i_rProperty, const css::uno::Sequence< OUString >& i_rChoices, + sal_Int32 i_nValue, + const css::uno::Sequence< sal_Bool >& i_rDisabledChoices = css::uno::Sequence< sal_Bool >(), + const UIControlOptions& i_rControlOptions = UIControlOptions()); + + /** Show an integer range (e.g. a spin field) + + note: max value < min value means do not apply min/max values + */ + static css::uno::Any setRangeControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, + const OUString& i_rProperty, sal_Int32 i_nValue, sal_Int32 i_nMinValue, + sal_Int32 i_nMaxValue, const UIControlOptions& i_rControlOptions); + + /** Show a string field + + note: max value < min value means do not apply min/max values + */ + static css::uno::Any setEditControlOpt( const OUString& i_rID, const OUString& i_rTitle, const OUString& i_rHelpId, + const OUString& i_rProperty, const OUString& i_rValue, + const UIControlOptions& i_rControlOptions); +}; // class PrinterOptionsHelper + +} // namespace vcl + + +#endif // INCLUDED_VCL_PRINT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/prntypes.hxx b/include/vcl/prntypes.hxx new file mode 100644 index 000000000..fab6a1bf6 --- /dev/null +++ b/include/vcl/prntypes.hxx @@ -0,0 +1,93 @@ +/* -*- 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_PRNTYPES_HXX +#define INCLUDED_VCL_PRNTYPES_HXX + +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> + + +// appears to be a copy of css::view::DuplexMode +enum class DuplexMode { Unknown, Off, LongEdge, ShortEdge }; + + +enum class Orientation { Portrait, Landscape }; + + +enum class PrintQueueFlags +{ + NONE = 0x00000000, + Ready = 0x00000001, + Paused = 0x00000002, + PendingDeletion = 0x00000004, + Busy = 0x00000008, + Initializing = 0x00000010, + Waiting = 0x00000020, + WarmingUp = 0x00000040, + Processing = 0x00000080, + Printing = 0x00000100, + Offline = 0x00000200, + Error = 0x00000400, + StatusUnknown = 0x00000800, + PaperJam = 0x00001000, + PaperOut = 0x00002000, + ManualFeed = 0x00004000, + PaperProblem = 0x00008000, + IOActive = 0x00010000, + OutputBinFull = 0x00020000, + TonerLow = 0x00040000, + NoToner = 0x00080000, + PagePunt = 0x00100000, + UserIntervention = 0x00200000, + OutOfMemory = 0x00400000, + DoorOpen = 0x00800000, + PowerSave = 0x01000000, +}; +namespace o3tl +{ + template<> struct typed_flags<PrintQueueFlags> : is_typed_flags<PrintQueueFlags, 0x01ffffff> {}; +} + +constexpr inline sal_uInt32 QUEUE_JOBS_DONTKNOW = 0xFFFFFFFF; + + +enum class PrinterCapType +{ + SupportDialog = 1, + Copies = 2, + CollateCopies = 3, + SetOrientation = 4, + SetPaperSize = 6, + SetPaper = 7, + Fax = 8, + PDF = 9, + ExternalDialog = 10, + UsePullModel = 12, +}; + +enum class PrinterSetupMode +{ + SingleJob = 0, + DocumentGlobal = 1 +}; + +#endif // INCLUDED_VCL_PRNTYPES_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/ptrstyle.hxx b/include/vcl/ptrstyle.hxx new file mode 100644 index 000000000..e2ae0238e --- /dev/null +++ b/include/vcl/ptrstyle.hxx @@ -0,0 +1,124 @@ +/* -*- 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_PTRSTYLE_HXX +#define INCLUDED_VCL_PTRSTYLE_HXX + +#include <com/sun/star/awt/SystemPointer.hpp> + +enum class PointerStyle +{ + Arrow = css::awt::SystemPointer::ARROW, + Null = css::awt::SystemPointer::INVISIBLE, + Wait = css::awt::SystemPointer::WAIT, + Text = css::awt::SystemPointer::TEXT, + Help = css::awt::SystemPointer::HELP, + Cross = css::awt::SystemPointer::CROSS, + Move = css::awt::SystemPointer::MOVE, + NSize = css::awt::SystemPointer::NSIZE, + SSize = css::awt::SystemPointer::SSIZE, + WSize = css::awt::SystemPointer::WSIZE, + ESize = css::awt::SystemPointer::ESIZE, + NWSize = css::awt::SystemPointer::NWSIZE, + NESize = css::awt::SystemPointer::NESIZE, + SWSize = css::awt::SystemPointer::SWSIZE, + SESize = css::awt::SystemPointer::SESIZE, + WindowNSize = css::awt::SystemPointer::WINDOW_NSIZE, + WindowSSize = css::awt::SystemPointer::WINDOW_SSIZE, + WindowWSize = css::awt::SystemPointer::WINDOW_WSIZE, + WindowESize = css::awt::SystemPointer::WINDOW_ESIZE, + WindowNWSize = css::awt::SystemPointer::WINDOW_NWSIZE, + WindowNESize = css::awt::SystemPointer::WINDOW_NESIZE, + WindowSWSize = css::awt::SystemPointer::WINDOW_SWSIZE, + WindowSESize = css::awt::SystemPointer::WINDOW_SESIZE, + HSplit = css::awt::SystemPointer::HSPLIT, + VSplit = css::awt::SystemPointer::VSPLIT, + HSizeBar = css::awt::SystemPointer::HSIZEBAR, + VSizeBar = css::awt::SystemPointer::VSIZEBAR, + Hand = css::awt::SystemPointer::HAND, + RefHand = css::awt::SystemPointer::REFHAND, + Pen = css::awt::SystemPointer::PEN, + Magnify = css::awt::SystemPointer::MAGNIFY, + Fill = css::awt::SystemPointer::FILL, + Rotate = css::awt::SystemPointer::ROTATE, + HShear = css::awt::SystemPointer::HSHEAR, + VShear = css::awt::SystemPointer::VSHEAR, + Mirror = css::awt::SystemPointer::MIRROR, + Crook = css::awt::SystemPointer::CROOK, + Crop = css::awt::SystemPointer::CROP, + MovePoint = css::awt::SystemPointer::MOVEPOINT, + MoveBezierWeight = css::awt::SystemPointer::MOVEBEZIERWEIGHT, + MoveData = css::awt::SystemPointer::MOVEDATA, + CopyData = css::awt::SystemPointer::COPYDATA, + LinkData = css::awt::SystemPointer::LINKDATA, + MoveDataLink = css::awt::SystemPointer::MOVEDATALINK, + CopyDataLink = css::awt::SystemPointer::COPYDATALINK, + MoveFile = css::awt::SystemPointer::MOVEFILE, + CopyFile = css::awt::SystemPointer::COPYFILE, + LinkFile = css::awt::SystemPointer::LINKFILE, + MoveFileLink = css::awt::SystemPointer::MOVEFILELINK, + CopyFileLink = css::awt::SystemPointer::COPYFILELINK, + MoveFiles = css::awt::SystemPointer::MOVEFILES, + CopyFiles = css::awt::SystemPointer::COPYFILES, + NotAllowed = css::awt::SystemPointer::NOTALLOWED, + DrawLine = css::awt::SystemPointer::DRAW_LINE, + DrawRect = css::awt::SystemPointer::DRAW_RECT, + DrawPolygon = css::awt::SystemPointer::DRAW_POLYGON, + DrawBezier = css::awt::SystemPointer::DRAW_BEZIER, + DrawArc = css::awt::SystemPointer::DRAW_ARC, + DrawPie = css::awt::SystemPointer::DRAW_PIE, + DrawCircleCut = css::awt::SystemPointer::DRAW_CIRCLECUT, + DrawEllipse = css::awt::SystemPointer::DRAW_ELLIPSE, + DrawFreehand = css::awt::SystemPointer::DRAW_FREEHAND, + DrawConnect = css::awt::SystemPointer::DRAW_CONNECT, + DrawText = css::awt::SystemPointer::DRAW_TEXT, + DrawCaption = css::awt::SystemPointer::DRAW_CAPTION, + Chart = css::awt::SystemPointer::CHART, + Detective = css::awt::SystemPointer::DETECTIVE, + PivotCol = css::awt::SystemPointer::PIVOT_COL, + PivotRow = css::awt::SystemPointer::PIVOT_ROW, + PivotField = css::awt::SystemPointer::PIVOT_FIELD, + Chain = css::awt::SystemPointer::CHAIN, + ChainNotAllowed = css::awt::SystemPointer::CHAIN_NOTALLOWED, + AutoScrollN, + AutoScrollS, + AutoScrollW, + AutoScrollE, + AutoScrollNW, + AutoScrollNE, + AutoScrollSW, + AutoScrollSE, + AutoScrollNS, + AutoScrollWE, + AutoScrollNSWE, + TextVertical, + PivotDelete, + TabSelectS, + TabSelectE, + TabSelectSE, + TabSelectW, + TabSelectSW, + HideWhitespace, + ShowWhitespace, + LAST = ShowWhitespace, +}; + +#endif // INCLUDED_VCL_PTRSTYLE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/quickselectionengine.hxx b/include/vcl/quickselectionengine.hxx new file mode 100644 index 000000000..87e1d09a9 --- /dev/null +++ b/include/vcl/quickselectionengine.hxx @@ -0,0 +1,91 @@ +/* -*- 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_QUICKSELECTIONENGINE_HXX +#define INCLUDED_VCL_QUICKSELECTIONENGINE_HXX + +#include <rtl/ustring.hxx> +#include <vcl/dllapi.h> +#include <memory> + +class KeyEvent; + + +namespace vcl +{ + + + typedef const void* StringEntryIdentifier; + + + //= ISearchableStringList + + // TODO: consolidate this with vcl::IMnemonicEntryList + class SAL_NO_VTABLE VCL_DLLPUBLIC ISearchableStringList + { + public: + /** returns the current entry in the list of searchable strings. + + Search operations will start with this entry. + */ + virtual StringEntryIdentifier CurrentEntry( OUString& _out_entryText ) const = 0; + + /** returns the next entry in the list. + + The implementation is expected to wrap around. That is, if the given entry denotes the last + entry in the list, then NextEntry should return the first entry. + */ + virtual StringEntryIdentifier NextEntry( StringEntryIdentifier _currentEntry, OUString& _out_entryText ) const = 0; + + /** selects a given entry + */ + virtual void SelectEntry( StringEntryIdentifier _entry ) = 0; + + protected: + ~ISearchableStringList() {} + }; + + + //= QuickSelectionEngine + + struct QuickSelectionEngine_Data; + class VCL_DLLPUBLIC QuickSelectionEngine + { + public: + QuickSelectionEngine( ISearchableStringList& _entryList ); + ~QuickSelectionEngine(); + + bool HandleKeyEvent( const KeyEvent& _rKEvt ); + void Reset(); + + private: + ::std::unique_ptr< QuickSelectionEngine_Data > m_pData; + + private: + QuickSelectionEngine( const QuickSelectionEngine& ) = delete; + QuickSelectionEngine& operator=( const QuickSelectionEngine& ) = delete; + }; + + +} // namespace vcl + + +#endif // INCLUDED_VCL_QUICKSELECTIONENGINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/region.hxx b/include/vcl/region.hxx new file mode 100644 index 000000000..0c8fad891 --- /dev/null +++ b/include/vcl/region.hxx @@ -0,0 +1,168 @@ +/* -*- 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_REGION_HXX +#define INCLUDED_VCL_REGION_HXX + +#include <tools/gen.hxx> +#include <vcl/dllapi.h> +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <memory> + +class RegionBand; + +namespace tools { + class Polygon; + class PolyPolygon; +} + +namespace vcl { class Window; } +class OutputDevice; +class Bitmap; + +typedef std::vector< tools::Rectangle > RectangleVector; + +namespace vcl { + +class SAL_WARN_UNUSED VCL_DLLPUBLIC Region +{ +private: + friend class ::OutputDevice; + friend class ::vcl::Window; + friend class ::Bitmap; + + // possible contents + std::shared_ptr< basegfx::B2DPolyPolygon > + mpB2DPolyPolygon; + std::shared_ptr< tools::PolyPolygon > + mpPolyPolygon; + std::shared_ptr< RegionBand > + mpRegionBand; + + bool mbIsNull : 1; + + // helpers + SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const tools::PolyPolygon& rPolyPoly ); + SAL_DLLPRIVATE void ImplCreatePolyPolyRegion( const basegfx::B2DPolyPolygon& rPolyPoly ); + + SAL_DLLPRIVATE tools::PolyPolygon ImplCreatePolyPolygonFromRegionBand() const; + SAL_DLLPRIVATE basegfx::B2DPolyPolygon ImplCreateB2DPolyPolygonFromRegionBand() const; + +public: + + explicit Region(bool bIsNull = false); // default creates empty region, with true a null region is created + explicit Region(const tools::Rectangle& rRect); + explicit Region(const tools::Polygon& rPolygon); + explicit Region(const tools::PolyPolygon& rPolyPoly); + explicit Region(const basegfx::B2DPolyPolygon&); + Region(const vcl::Region& rRegion); + Region(vcl::Region&& rRegion) noexcept; + ~Region(); + + // direct access to contents + const basegfx::B2DPolyPolygon* getB2DPolyPolygon() const { return mpB2DPolyPolygon.get(); } + const tools::PolyPolygon* getPolyPolygon() const { return mpPolyPolygon.get(); } + const RegionBand* getRegionBand() const { return mpRegionBand.get(); } + + // access with converters, the asked data will be created from the most + // valuable data, buffered and returned + tools::PolyPolygon GetAsPolyPolygon() const; + basegfx::B2DPolyPolygon GetAsB2DPolyPolygon() const; + const RegionBand* GetAsRegionBand() const; + + // manipulators + void Move( long nHorzMove, long nVertMove ); + void Scale( double fScaleX, double fScaleY ); + void Union( const tools::Rectangle& rRegion ); + void Intersect( const tools::Rectangle& rRegion ); + void Exclude( const tools::Rectangle& rRegion ); + void XOr( const tools::Rectangle& rRegion ); + void Union( const vcl::Region& rRegion ); + void Intersect( const vcl::Region& rRegion ); + void Exclude( const vcl::Region& rRegion ); + bool XOr( const vcl::Region& rRegion ); + + bool IsEmpty() const; + bool IsNull() const { return mbIsNull;} + + void SetEmpty(); + void SetNull(); + + bool IsRectangle() const; + + tools::Rectangle GetBoundRect() const; + bool HasPolyPolygonOrB2DPolyPolygon() const { return (getB2DPolyPolygon() || getPolyPolygon()); } + void GetRegionRectangles(RectangleVector& rTarget) const; + + bool IsInside( const Point& rPoint ) const; + bool IsOver( const tools::Rectangle& rRect ) const; + + vcl::Region& operator=( const vcl::Region& rRegion ); + vcl::Region& operator=( vcl::Region&& rRegion ) noexcept; + vcl::Region& operator=( const tools::Rectangle& rRect ); + + bool operator==( const vcl::Region& rRegion ) const; + bool operator!=( const vcl::Region& rRegion ) const { return !(Region::operator==( rRegion )); } + + friend VCL_DLLPUBLIC SvStream& ReadRegion( SvStream& rIStm, vcl::Region& rRegion ); + friend VCL_DLLPUBLIC SvStream& WriteRegion( SvStream& rOStm, const vcl::Region& rRegion ); + + /* workaround: faster conversion for PolyPolygons + * if half of the Polygons contained in rPolyPoly are actually + * rectangles, then the returned vcl::Region will be constructed by + * XOr'ing the contained Polygons together; in the case of + * only Rectangles this can be up to eight times faster than + * Region( const tools::PolyPolygon& ). + * Caution: this is only useful if the vcl::Region is known to be + * changed to rectangles; e.g. if being set as clip region + */ + static vcl::Region GetRegionFromPolyPolygon( const tools::PolyPolygon& rPolyPoly ); +}; + +} /* namespace vcl */ + +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const vcl::Region& rRegion) +{ + if (rRegion.IsEmpty()) + return stream << "EMPTY"; + if (rRegion.getB2DPolyPolygon()) + return stream << "B2DPolyPolygon(" + << *rRegion.getB2DPolyPolygon() + << ")"; + if (rRegion.getPolyPolygon()) + return stream << "unimplemented"; + if (rRegion.getRegionBand()) + { // inlined because RegionBand is private to vcl + stream << "RegionBand("; + RectangleVector rects; + rRegion.GetRegionRectangles(rects); + if (rects.empty()) + stream << "EMPTY"; + for (size_t i = 0; i < rects.size(); ++i) + stream << "[" << i << "] " << rects[i]; + stream << ")"; + } + return stream; +} + +#endif // INCLUDED_VCL_REGION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/roadmapwizard.hxx b/include/vcl/roadmapwizard.hxx new file mode 100644 index 000000000..6a55bacad --- /dev/null +++ b/include/vcl/roadmapwizard.hxx @@ -0,0 +1,189 @@ +/* -*- 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_ROADMAPWIZARD_HXX +#define INCLUDED_VCL_ROADMAPWIZARD_HXX + +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/wizardmachine.hxx> + +namespace vcl +{ + struct RoadmapWizardImpl; + + namespace RoadmapWizardTypes + { + typedef sal_Int16 PathId; + typedef ::std::vector< WizardTypes::WizardState > WizardPath; + }; + + //= RoadmapWizard + + /** is - no, not a wizard for a roadmap, but the base class for wizards + <em>supporting</em> a roadmap. + + The basic new concept introduced is a <em>path</em>:<br/> + A <em>path</em> is a sequence of states, which are to be executed in a linear order. + Elements in the path can be skipped, depending on choices the user makes. + + In the most simple wizards, you will have only one path consisting of <code>n</code> elements, + which are to be visited successively. + + In a slightly more complex wizard, you will have one linear path, were certain + steps might be skipped due to user input. For instance, the user may decide to not specify + certain aspects of the to-be-created object (e.g. by unchecking a check box), + and the wizard then will simply disable the step which corresponds to this step. + + In a yet more advanced wizards, you will have several paths of length <code>n1</code> and + <code>n2</code>, which share at least the first <code>k</code> states (where <code>k</code> + is at least 1), and an arbitrary number of other states. + */ + class VCL_DLLPUBLIC RoadmapWizardMachine : public vcl::WizardMachine + { + private: + std::unique_ptr<RoadmapWizardImpl> m_pImpl; + + public: + RoadmapWizardMachine(weld::Window* _pParent); + virtual ~RoadmapWizardMachine( ) override; + + void SetRoadmapHelpId( const OString& _rId ); + + // returns whether a given state is enabled + bool isStateEnabled(WizardTypes::WizardState nState) const; + + // WizardDialog overridables + virtual bool canAdvance() const override; + virtual void updateTravelUI() override; + + protected: + /** declares a valid path in the wizard + + The very first path which is declared is automatically activated. + + Note that all paths which are declared must have the very first state in + common. Also note that due to a restriction of the very base class (WizardDialog), + this common first state must be 0. + + You cannot declare new paths once the wizard started, so it's recommended that + you do all declarations within your derivee's constructor. + + @see activatePath + + @param _nId + the unique id you wish to give this path. This id can later on be used + to refer to the path which you just declared + */ + void declarePath( RoadmapWizardTypes::PathId _nPathId, const RoadmapWizardTypes::WizardPath& _lWizardStates); + + /** activates a path which has previously been declared with <member>declarePath</member> + + You can only activate paths which share the first <code>k</code> states with the path + which is previously active (if any), where <code>k</code> is the index of the + current state within the current path. + + <example> + Say you have paths, <code>(0,1,2,5)</code> and <code>(0,1,4,5)</code>. This means that after + step <code>1</code>, you either continue with state <code>2</code> or state <code>4</code>, + and after this, you finish in state <code>5</code>.<br/> + Now if the first path is active, and your current state is <code>1</code>, then you can + easily switch to the second path, since both paths start with <code>(0,1)</code>.<br/> + However, if your current state is <code>2</code>, then you can not switch to the second + path anymore. + </example> + + @param _nPathId + the id of the path. The path must have been declared (under this id) with + <member>declarePath</member> before it can be activated. + + @param _bDecideForIt + If <TRUE/>, the path will be completely activated, even if it is a conflicting path + (i.e. there is another path which shares the first <code>k</code> states with + the to-be-activated path.)<br/> + If <FALSE/>, then the new path is checked for conflicts with other paths. If such + conflicts exists, the path is not completely activated, but only up to the point + where it does <em>not</em> conflict.<br/> + With the paths in the example above, if you activate the second path (when both are + already declared), then only steps <code>0</code> and <code>1</code> are activated, + since they are common to both paths. + */ + void activatePath( RoadmapWizardTypes::PathId _nPathId, bool _bDecideForIt = false ); + + /** determine the next state to travel from the given one + + This method (which is declared in WizardMachine and overwritten here) + ensures that traveling happens along the active path. + + @see activatePath + */ + virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const override; + + /** en- or disables a state + + In the wizard's roadmap, states to travel to can be freely chosen. To prevent + users from selecting a state which is currently not available, you can declare this + state as being disabled. + + A situation where you need this may be when you have a checkbox which, when checked + by the user, enables a page with additional settings. As long as this checkbox is + not checked, the respective state would be disabled. + + Note that in theory, you can declare multiple paths, instead of disabling states. + For instance, if you have a path where one state can be potentially disabled, then + you could declare a second path, which does not contain this state. However, the + disadvantage is that then, not the complete path would be visible in the roadmap, + but only all steps up to the point where the both paths diverge.<br/> + Another disadvantage is that the number of needed paths grows exponentially with + the number of states which can be potentially disabled. + + @see declarePath + */ + void enableState(WizardTypes::WizardState nState, bool _bEnable = true); + + /** returns true if and only if the given state is known in at least one declared path + */ + bool knowsState(WizardTypes::WizardState nState) const; + + // WizardMachine overriables + virtual void enterState(WizardTypes::WizardState nState) override; + + /** returns a human readable name for a given state + + There is a default implementation for this method, which returns the display name + as given in a call to describeState. If there is no description for the given state, + this is worth an assertion in a non-product build, and then an empty string is + returned. + */ + virtual OUString getStateDisplayName(WizardTypes::WizardState nState) const; + + private: + DECL_DLLPRIVATE_LINK( OnRoadmapItemSelected, const OString&, bool ); + + /** updates the roadmap control to show the given path, as far as possible + (modulo conflicts with other paths) + */ + VCL_DLLPRIVATE void implUpdateRoadmap( ); + }; +} // namespace vcl + + +#endif // OOO_ INCLUDED_VCL_ROADMAPWIZARD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/salctype.hxx b/include/vcl/salctype.hxx new file mode 100644 index 000000000..409fc5a79 --- /dev/null +++ b/include/vcl/salctype.hxx @@ -0,0 +1,63 @@ +/* -*- 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_SALCTYPE_HXX +#define INCLUDED_VCL_SALCTYPE_HXX + +#include <sal/config.h> + +#include <vcl/graph.hxx> + +enum class ConvertDataFormat +{ + Unknown, + BMP, + GIF, + JPG, + MET, + PCT, + PNG, + SVM, + TIF, + WMF, + EMF, + SVG +}; + +class SvStream; + +struct ConvertData +{ +public: + + Graphic maGraphic; + SvStream& mrStm; + ConvertDataFormat mnFormat; + + ConvertData( const Graphic& rGraphic, SvStream& rStm, ConvertDataFormat nFormat ) : + maGraphic( rGraphic ), mrStm( rStm ), mnFormat( nFormat ) {} +}; + +typedef sal_uLong (*SALGRFCVTPROC)( void* pInst, + ConvertDataFormat nInFormat, void* pInBuffer, sal_uLong nInBufSize, + ConvertDataFormat nOutFormat, void** ppOutBuffer ); + +#endif // INCLUDED_VCL_SALCTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/salgtype.hxx b/include/vcl/salgtype.hxx new file mode 100644 index 000000000..3c1f59512 --- /dev/null +++ b/include/vcl/salgtype.hxx @@ -0,0 +1,96 @@ +/* -*- 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_SALGTYPE_HXX +#define INCLUDED_VCL_SALGTYPE_HXX + +#include <o3tl/typed_flags_set.hxx> +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <ostream> + +enum class DeviceFormat { + NONE = -1, + DEFAULT = 0, + BITMASK = 1, +#ifdef IOS + GRAYSCALE = 8 +#endif + }; + +constexpr ::Color SALCOLOR_NONE ( 0xFF, 0xFF, 0xFF, 0xFF ); + +// must equal to class Point +struct SalPoint +{ + long mnX; + long mnY; +}; + +typedef const SalPoint* PCONSTSALPOINT; + +struct SalTwoRect +{ + long mnSrcX; + long mnSrcY; + long mnSrcWidth; + long mnSrcHeight; + long mnDestX; + long mnDestY; + long mnDestWidth; + long mnDestHeight; + + SalTwoRect(long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, + long nDestX, long nDestY, long nDestWidth, long nDestHeight) + : mnSrcX(nSrcX), mnSrcY(nSrcY), mnSrcWidth(nSrcWidth), mnSrcHeight(nSrcHeight) + , mnDestX(nDestX), mnDestY(nDestY), mnDestWidth(nDestWidth), mnDestHeight(nDestHeight) + { + } +}; + +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const SalTwoRect& rPosAry) +{ + tools::Rectangle aSrcRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcX + rPosAry.mnSrcWidth, + rPosAry.mnSrcY + rPosAry.mnSrcHeight); + tools::Rectangle aDestRect(rPosAry.mnDestX, rPosAry.mnDestY, + rPosAry.mnDestX + rPosAry.mnDestWidth, + rPosAry.mnDestY + rPosAry.mnDestHeight); + stream << aSrcRect << " => " << aDestRect; + return stream; +} + +enum class SalROPColor { + N0, N1, Invert +}; + +enum class SalInvert { + NONE = 0x00, + N50 = 0x01, + TrackFrame = 0x02 +}; +namespace o3tl +{ + template<> struct typed_flags<SalInvert> : is_typed_flags<SalInvert, 0x03> {}; +} + +#endif // INCLUDED_VCL_SALGTYPE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/salnativewidgets.hxx b/include/vcl/salnativewidgets.hxx new file mode 100644 index 000000000..b53331484 --- /dev/null +++ b/include/vcl/salnativewidgets.hxx @@ -0,0 +1,540 @@ +/* -*- 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_SALNATIVEWIDGETS_HXX +#define INCLUDED_VCL_SALNATIVEWIDGETS_HXX + +#include <vcl/dllapi.h> +#include <tools/gen.hxx> +#include <o3tl/typed_flags_set.hxx> + +/* Control Types: + * + * Specify the overall, whole control + * type (as opposed to parts of the + * control if it were composite). + */ + +enum class ControlType { +// for use in general purpose ImplControlValue + Generic = 0, +// Normal PushButton/Command Button + Pushbutton = 1, +// Normal single radio button + Radiobutton = 2, +// Normal single checkbox + Checkbox = 10, +// Combobox, i.e. a ListBox +// that allows data entry by user + Combobox = 20, +// Control that allows text entry + Editbox = 30, +// Control that allows text entry, but without the usual border +// Has to be handled separately, because this one cannot handle +// ControlPart::HasBackgroundTexture, which is drawn in the edit box'es +// border window. + EditboxNoBorder = 31, +// Control that allows text entry +// ( some systems distinguish between single and multi line edit boxes ) + MultilineEditbox = 32, +// Control that pops up a menu, +// but does NOT allow data entry + Listbox = 35, +// An edit field together with two little +// buttons on the side (aka spin field) + Spinbox = 40, +// Two standalone spin buttons +// without an edit field + SpinButtons = 45, +// A single tab + TabItem = 50, +// The border around a tab area, +// but without the tabs themselves. +// May have a gap at the top for +// the active tab + TabPane = 55, +// The background to the tab area + TabHeader = 56, +// Background of a Tab Pane + TabBody = 57, +// Normal scrollbar, including +// all parts like slider, buttons + Scrollbar = 60, + Slider = 65, +// A separator line + Fixedline = 80, +// A toolbar control with buttons and a grip + Toolbar = 100, +// The menubar + Menubar = 120, +// popup menu + MenuPopup = 121, + Progress = 131, +// Progress bar for the intro window +// (aka splash screen), in case some +// wants native progress bar in the +// application but not for the splash +// screen (used in desktop/) + IntroProgress = 132, +// tool tips + Tooltip = 140, +// to draw the implemented theme + WindowBackground = 150, +//to draw border of frames natively + Frame = 160, +// for nodes in listviews +// used in svtools/source/contnr/svtreebx.cxx + ListNode = 170, +// nets between elements of listviews +// with nodes + ListNet = 171, +// for list headers + ListHeader = 172, +}; + + +/* Control Parts: + * + * Uniquely identify a part of a control, + * for example the slider of a scroll bar. + */ + +enum class ControlPart +{ + NONE = 0, + Entire = 1, + ListboxWindow = 5, // the static listbox window containing the list + Button = 100, + ButtonUp = 101, + ButtonDown = 102, // Also for ComboBoxes/ListBoxes + ButtonLeft = 103, + ButtonRight = 104, + AllButtons = 105, + SeparatorHorz = 106, + SeparatorVert = 107, + TrackHorzLeft = 200, + TrackVertUpper = 201, + TrackHorzRight = 202, + TrackVertLower = 203, + TrackHorzArea = 204, + TrackVertArea = 205, + Arrow = 220, + ThumbHorz = 210, // Also used as toolbar grip + ThumbVert = 211, // Also used as toolbar grip + MenuItem = 250, + MenuItemCheckMark = 251, + MenuItemRadioMark = 252, + Separator = 253, + SubmenuArrow = 254, + +/* #i77549# + HACK: for scrollbars in case of thumb rect, page up and page down rect we + abuse the HitTestNativeScrollbar interface. All theming engines but aqua + are actually able to draw the thumb according to our internal representation. + However aqua draws a little outside. The canonical way would be to enhance the + HitTestNativeScrollbar passing a ScrollbarValue additionally so all necessary + information is available in the call. + . + However since there is only this one small exception we will deviate a little and + instead pass the respective rect as control region to allow for a small correction. + + So all places using HitTestNativeScrollbar on ControlPart::ThumbHorz, ControlPart::ThumbVert, + ControlPart::TrackHorzLeft, ControlPart::TrackHorzRight, ControlPart::TrackVertUpper, ControlPart::TrackVertLower + do not use the control rectangle as region but the actual part rectangle, making + only small deviations feasible. +*/ + +/** The edit field part of a control, e.g. of the combo box. + + Currently used just for combo boxes and just for GetNativeControlRegion(). + It is valid only if GetNativeControlRegion() supports ControlPart::ButtonDown as + well. +*/ + SubEdit = 300, + +// For controls that require the entire background +// to be drawn first, and then other pieces over top. +// (GTK+ scrollbars for example). Control region passed +// in to draw this part is expected to be the entire +// area of the control. +// A control may respond to one or both. + DrawBackgroundHorz = 1000, + DrawBackgroundVert = 1001, + +// GTK+ also draws tabs right->left since there is a +// hardcoded 2 pixel overlap between adjacent tabs + TabsDrawRtl = 3000, + +// Qt doesn't have a separate header to draw + TabPaneWithHeader = 3001, + +// For themes that do not want to have the focus +// rectangle part drawn by VCL but take care of the +// whole inner control part by themselves +// eg, listboxes or comboboxes or spinbuttons + HasBackgroundTexture = 4000, + +// For scrollbars that have 3 buttons (most KDE themes) + HasThreeButtons = 5000, + + BackgroundWindow = 6000, + BackgroundDialog = 6001, + +//to draw natively the border of frames + Border = 7000, + +//to draw natively the focus rects + Focus = 8000 +}; + +/* Control State: + * + * Specify how a particular part of the control + * is to be drawn. Constants are bitwise OR-ed + * together to compose a final drawing state. + * A _disabled_ state is assumed by the drawing + * functions until an ENABLED or HIDDEN is passed + * in the ControlState. + */ +enum class ControlState { + NONE = 0, + ENABLED = 0x0001, + FOCUSED = 0x0002, + PRESSED = 0x0004, + ROLLOVER = 0x0008, + DEFAULT = 0x0020, + SELECTED = 0x0040 +}; +namespace o3tl +{ + template<> struct typed_flags<ControlState> : is_typed_flags<ControlState, 0x006f> {}; +} + +/* ButtonValue: + * + * Identifies the tri-state value options + * that buttons allow + */ + +enum class ButtonValue { + DontKnow, + On, + Off, + Mixed +}; + +/* ImplControlValue: + * + * Generic value container for all control parts. + */ + +class VCL_DLLPUBLIC ImplControlValue +{ + friend class SalFrame; + + private: + ControlType mType; + ButtonValue mTristate; // Tristate value: on, off, mixed + long mNumber; // numeric value + protected: + ImplControlValue( ControlType i_eType, long i_nNumber ) + : mType( i_eType ) + , mTristate( ButtonValue::DontKnow ) + , mNumber( i_nNumber ) + {} + + public: + explicit ImplControlValue( ButtonValue nTristate ) + : mType( ControlType::Generic ), mTristate(nTristate), mNumber(0) {} + explicit ImplControlValue( long nNumeric ) + : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber( nNumeric) {} + ImplControlValue() + : mType( ControlType::Generic ), mTristate(ButtonValue::DontKnow), mNumber(0) {} + + virtual ~ImplControlValue(); + + ImplControlValue(ImplControlValue const &) = default; + ImplControlValue(ImplControlValue &&) = default; + ImplControlValue & operator =(ImplControlValue const &) = delete; // due to const mType + ImplControlValue & operator =(ImplControlValue &&) = delete; // due to const mType + + virtual ImplControlValue* clone() const; + + ControlType getType() const { return mType; } + + ButtonValue getTristateVal() const { return mTristate; } + void setTristateVal( ButtonValue nTristate ) { mTristate = nTristate; } + + long getNumericVal() const { return mNumber; } + void setNumericVal( long nNumeric ) { mNumber = nNumeric; } +}; + +/* ScrollbarValue: + * + * Value container for scrollbars. + */ +class SAL_DLLPUBLIC_RTTI ScrollbarValue final : public ImplControlValue +{ + public: + long mnMin; + long mnMax; + long mnCur; + long mnVisibleSize; + tools::Rectangle maThumbRect; + tools::Rectangle maButton1Rect; + tools::Rectangle maButton2Rect; + ControlState mnButton1State; + ControlState mnButton2State; + ControlState mnThumbState; + + ScrollbarValue() + : ImplControlValue( ControlType::Scrollbar, 0 ) + { + mnMin = 0; mnMax = 0; mnCur = 0; mnVisibleSize = 0; + mnButton1State = ControlState::NONE; mnButton2State = ControlState::NONE; + mnThumbState = ControlState::NONE; + }; + virtual ~ScrollbarValue() override; + virtual ScrollbarValue* clone() const override; + + ScrollbarValue(ScrollbarValue const &) = default; + ScrollbarValue(ScrollbarValue &&) = default; + ScrollbarValue & operator =(ScrollbarValue const &) = delete; // due to ImplControlValue + ScrollbarValue & operator =(ScrollbarValue &&) = delete; // due to ImplControlValue +}; + +class SAL_DLLPUBLIC_RTTI SliderValue final : public ImplControlValue +{ + public: + long mnMin; + long mnMax; + long mnCur; + tools::Rectangle maThumbRect; + ControlState mnThumbState; + + SliderValue() + : ImplControlValue( ControlType::Slider, 0 ) + , mnMin( 0 ), mnMax( 0 ), mnCur( 0 ), mnThumbState( ControlState::NONE ) + {} + virtual ~SliderValue() override; + virtual SliderValue* clone() const override; + + SliderValue(SliderValue const &) = default; + SliderValue(SliderValue &&) = default; + SliderValue & operator =(SliderValue const &) = delete; // due to ImplControlValue + SliderValue & operator =(SliderValue &&) = delete; // due to ImplControlValue +}; + +class VCL_DLLPUBLIC TabPaneValue final : public ImplControlValue +{ +public: + tools::Rectangle m_aTabHeaderRect; + tools::Rectangle m_aSelectedTabRect; + // increased tab size, so it'll overlab the frame rect when drawing + // static value, as there is currently no sane way to return additional data + static int m_nOverlap; + + TabPaneValue(const tools::Rectangle &rTabHeaderRect, const tools::Rectangle &rSelectedTabRect) + : ImplControlValue(ControlType::TabPane, 0) + , m_aTabHeaderRect(rTabHeaderRect) + , m_aSelectedTabRect(rSelectedTabRect) + { + } + TabPaneValue* clone() const override; + + TabPaneValue(TabPaneValue const &) = default; + TabPaneValue(TabPaneValue &&) = default; + TabPaneValue & operator =(TabPaneValue const &) = delete; + TabPaneValue & operator =(TabPaneValue &&) = delete; +}; + +/* TabitemValue: + * + * Value container for tabitems. + */ + +/* TABITEM constants are OR-ed together */ +enum class TabitemFlags +{ + NONE = 0x00, + LeftAligned = 0x01, // the tabitem is aligned with the left border of the TabControl + RightAligned = 0x02, // the tabitem is aligned with the right border of the TabControl + FirstInGroup = 0x04, // the tabitem is the first in group of tabitems + LastInGroup = 0x08, // the tabitem is the last in group of tabitems +}; +namespace o3tl +{ + template<> struct typed_flags<TabitemFlags> : is_typed_flags<TabitemFlags, 0x0f> {}; +} + +class SAL_DLLPUBLIC_RTTI TabitemValue final : public ImplControlValue +{ + public: + TabitemFlags mnAlignment; + tools::Rectangle maContentRect; + + TabitemValue(const tools::Rectangle &rContentRect) + : ImplControlValue( ControlType::TabItem, 0 ) + , mnAlignment(TabitemFlags::NONE) + , maContentRect(rContentRect) + { + } + virtual ~TabitemValue() override; + virtual TabitemValue* clone() const override; + + TabitemValue(TabitemValue const &) = default; + TabitemValue(TabitemValue &&) = default; + TabitemValue & operator =(TabitemValue const &) = delete; // due to ImplControlValue + TabitemValue & operator =(TabitemValue &&) = delete; // due to ImplControlValue + + bool isLeftAligned() const { return bool(mnAlignment & TabitemFlags::LeftAligned); } + bool isRightAligned() const { return bool(mnAlignment & TabitemFlags::RightAligned); } + bool isBothAligned() const { return isLeftAligned() && isRightAligned(); } + bool isNotAligned() const { return !(mnAlignment & (TabitemFlags::LeftAligned | TabitemFlags::RightAligned)); } + bool isFirst() const { return bool(mnAlignment & TabitemFlags::FirstInGroup); } + bool isLast() const { return bool(mnAlignment & TabitemFlags::LastInGroup); } + const tools::Rectangle& getContentRect() const { return maContentRect; } +}; + +/* SpinbuttonValue: + * + * Value container for spinbuttons to paint both buttons at once. + * Note: the other parameters of DrawNativeControl will have no meaning + * all parameters for spinbuttons are carried here + */ +class SAL_DLLPUBLIC_RTTI SpinbuttonValue final : public ImplControlValue +{ + public: + tools::Rectangle maUpperRect; + tools::Rectangle maLowerRect; + ControlState mnUpperState; + ControlState mnLowerState; + ControlPart mnUpperPart; + ControlPart mnLowerPart; + + SpinbuttonValue() + : ImplControlValue( ControlType::SpinButtons, 0 ) + , mnUpperState(ControlState::NONE) + , mnLowerState(ControlState::NONE) + , mnUpperPart(ControlPart::NONE) + , mnLowerPart(ControlPart::NONE) + { + } + + virtual ~SpinbuttonValue() override; + virtual SpinbuttonValue* clone() const override; + + SpinbuttonValue(SpinbuttonValue const &) = default; + SpinbuttonValue(SpinbuttonValue &&) = default; + SpinbuttonValue & operator =(SpinbuttonValue const &) = delete; // due to ImplControlValue + SpinbuttonValue & operator =(SpinbuttonValue &&) = delete; // due to ImplControlValue +}; + +/* Toolbarvalue: + * + * Value container for toolbars detailing the grip position + */ +class ToolbarValue final : public ImplControlValue +{ +public: + ToolbarValue() : ImplControlValue( ControlType::Toolbar, 0 ) + { mbIsTopDockingArea = false; } + virtual ~ToolbarValue() override; + virtual ToolbarValue* clone() const override; + + ToolbarValue(ToolbarValue const &) = default; + ToolbarValue(ToolbarValue &&) = default; + ToolbarValue & operator =(ToolbarValue const &) = delete; // due to ImplControlValue + ToolbarValue & operator =(ToolbarValue &&) = delete; // due to ImplControlValue + + tools::Rectangle maGripRect; + bool mbIsTopDockingArea; // indicates that this is the top aligned dockingarea + // adjacent to the menubar, only used on Windows +}; + +/* MenubarValue: + * + * Value container for menubars specifying height of adjacent docking area + */ +class MenubarValue final : public ImplControlValue +{ +public: + MenubarValue() : ImplControlValue( ControlType::Menubar, 0 ) + { maTopDockingAreaHeight=0; } + virtual ~MenubarValue() override; + virtual MenubarValue* clone() const override; + MenubarValue(MenubarValue const &) = default; + MenubarValue(MenubarValue &&) = default; + MenubarValue & operator =(MenubarValue const &) = delete; // due to ImplControlValue + MenubarValue & operator =(MenubarValue &&) = delete; // due to ImplControlValue + int maTopDockingAreaHeight; +}; + +/* MenupopupValue: + * + * Value container for menu items; specifies the rectangle for the whole item which + * may be useful when drawing parts with a smaller rectangle. + */ +class SAL_DLLPUBLIC_RTTI MenupopupValue final : public ImplControlValue +{ +public: + MenupopupValue( long i_nGutterWidth, const tools::Rectangle& i_rItemRect ) + : ImplControlValue( ControlType::MenuPopup, i_nGutterWidth ) + , maItemRect( i_rItemRect ) + {} + virtual ~MenupopupValue() override; + virtual MenupopupValue* clone() const override; + MenupopupValue(MenupopupValue const &) = default; + MenupopupValue(MenupopupValue &&) = default; + MenupopupValue & operator =(MenupopupValue const &) = delete; // due to ImplControlValue + MenupopupValue & operator =(MenupopupValue &&) = delete; // due to ImplControlValue + tools::Rectangle maItemRect; +}; + +/* PushButtonValue: + * + * Value container for pushbuttons specifying additional drawing hints + */ +class VCL_DLLPUBLIC PushButtonValue final : public ImplControlValue +{ +public: + PushButtonValue() + : ImplControlValue( ControlType::Pushbutton, 0 ) + , mbBevelButton(false) + , mbSingleLine(true) + , mbIsAction(false) + {} + + virtual ~PushButtonValue() override; + virtual PushButtonValue* clone() const override; + + PushButtonValue(PushButtonValue const &) = default; + PushButtonValue(PushButtonValue &&) = default; + PushButtonValue & operator =(PushButtonValue const &) = delete; // due to ImplControlValue + PushButtonValue & operator =(PushButtonValue &&) = delete; // due to ImplControlValue + + bool mbBevelButton:1; // only used on OSX + bool mbSingleLine:1; // only used on OSX + bool mbIsAction:1; +}; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/scheduler.hxx b/include/vcl/scheduler.hxx new file mode 100644 index 000000000..9318b2109 --- /dev/null +++ b/include/vcl/scheduler.hxx @@ -0,0 +1,85 @@ +/* -*- 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_SCHEDULER_HXX +#define INCLUDED_VCL_SCHEDULER_HXX + +#include <vcl/dllapi.h> + +struct ImplSchedulerContext; + +class VCL_DLLPUBLIC Scheduler final +{ + friend class SchedulerGuard; + friend class Task; + Scheduler() = delete; + + static inline void UpdateSystemTimer( ImplSchedulerContext &rSchedCtx, + sal_uInt64 nMinPeriod, + bool bForce, sal_uInt64 nTime ); + + static void ImplStartTimer ( sal_uInt64 nMS, bool bForce, sal_uInt64 nTime ); + + static void Lock( sal_uInt32 nLockCount = 1 ); + static sal_uInt32 Unlock( bool bUnlockAll = false ); + +public: + static constexpr sal_uInt64 ImmediateTimeoutMs = 0; + static constexpr sal_uInt64 InfiniteTimeoutMs = SAL_MAX_UINT64; + + static void ImplDeInitScheduler(); + + /// Process one pending Timer with highest priority + static void CallbackTaskScheduling(); + /// Process one pending task ahead of time with highest priority. + static bool ProcessTaskScheduling(); + /** + * Process all events until none is pending + * + * This can busy-lock, if some task or system event always generates new + * events when being processed. Most time it's called in unit tests to + * process all pending events. Internally it just calls + * Application::Reschedule( true ) until it fails. + * + * @see Application::Reschedule + */ + static void ProcessEventsToIdle(); + + /** + * Wakes up the scheduler + * + * This doesn't handle any events! It just ensures the Scheduler is run as + * soon as possible by forcing the Scheduler timer to fire. + * + * Can be used for complex UpdateMinPeriod function, where the task is + * actually active but not ready and we want to skip the Task::Start() + * queue append for faster reaction. + */ + static void Wakeup(); + + /// Control the deterministic mode. In this mode, two subsequent runs of + /// LibreOffice fire about the same amount idles. + static void SetDeterministicMode(bool bDeterministic); + /// Return the current state of deterministic mode. + static bool GetDeterministicMode(); +}; + +#endif // INCLUDED_VCL_SCHEDULER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/scopedbitmapaccess.hxx b/include/vcl/scopedbitmapaccess.hxx new file mode 100644 index 000000000..f63bcc55f --- /dev/null +++ b/include/vcl/scopedbitmapaccess.hxx @@ -0,0 +1,121 @@ +/* -*- 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_SCOPEDBITMAPACCESS_HXX +#define INCLUDED_VCL_SCOPEDBITMAPACCESS_HXX + +namespace vcl +{ + +/** This template handles BitmapAccess the RAII way. + + Please don't use directly, but through the ready-made typedefs + ScopedReadAccess and ScopedWriteAccess in classes Bitmap and + AlphaMask. + + Use as follows: + Bitmap aBitmap; + Bitmap::ScopedReadAccess pReadAccess( aBitmap ); + pReadAccess->SetPixel()... + + Bitmap aBitmap2; + BitmapScopedWriteAccess pWriteAccess( bCond ? aBitmap2.AcquireWriteAccess() : 0, aBitmap2 ); + if ( pWriteAccess )... + + @attention for practical reasons, ScopedBitmapAccess stores a + reference to the provided bitmap, thus, make sure that the bitmap + specified at construction time lives at least as long as the + ScopedBitmapAccess. + */ +template < class Access, class Bitmap, Access* (Bitmap::* Acquire)() > class ScopedBitmapAccess +{ +public: + explicit ScopedBitmapAccess( Bitmap& rBitmap ) : + mpAccess( nullptr ), + mpBitmap( &rBitmap ) + { + mpAccess = (mpBitmap->*Acquire)(); + } + + ScopedBitmapAccess( Access* pAccess, Bitmap& rBitmap ) : + mpAccess( pAccess ), + mpBitmap( &rBitmap ) + { + } + + ScopedBitmapAccess( ) : + mpAccess( nullptr ), + mpBitmap( nullptr ) + { + } + + // Move semantics + ScopedBitmapAccess &operator=(ScopedBitmapAccess&&other) + { + mpAccess=other.mpAccess; + mpBitmap=other.mpBitmap; + other.mpAccess = nullptr; + other.mpBitmap = nullptr; + return *this; + } + + // Disable copy from lvalue. + ScopedBitmapAccess(const ScopedBitmapAccess&) = delete; + ScopedBitmapAccess &operator=(const ScopedBitmapAccess&) = delete; + + ~ScopedBitmapAccess() COVERITY_NOEXCEPT_FALSE + { + if (mpAccess) + mpBitmap->ReleaseAccess( mpAccess ); + } + + void reset() + { + if (mpAccess) + { + mpBitmap->ReleaseAccess( mpAccess ); + mpAccess = nullptr; + } + } + + bool operator!() const { return !mpAccess; } + explicit operator bool() const + { + return mpAccess; + } + + Access* get() { return mpAccess; } + const Access* get() const { return mpAccess; } + + Access* operator->() { return mpAccess; } + const Access* operator->() const { return mpAccess; } + + Access& operator*() { return *mpAccess; } + const Access& operator*() const { return *mpAccess; } + +private: + Access* mpAccess; + Bitmap* mpBitmap; +}; + +} + +#endif // INCLUDED_VCL_SCOPEDBITMAPACCESS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx new file mode 100644 index 000000000..e3474ee0a --- /dev/null +++ b/include/vcl/scrbar.hxx @@ -0,0 +1,158 @@ +/* -*- 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_SCRBAR_HXX +#define INCLUDED_VCL_SCRBAR_HXX + +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <memory> + + +enum class ScrollType +{ + DontKnow, + LineUp, LineDown, + PageUp, PageDown, + Drag +}; + + +struct ImplScrollBarData; + +class VCL_DLLPUBLIC ScrollBar : public Control +{ +private: + tools::Rectangle maBtn1Rect; + tools::Rectangle maBtn2Rect; + tools::Rectangle maPage1Rect; + tools::Rectangle maPage2Rect; + tools::Rectangle maThumbRect; + tools::Rectangle maTrackRect; + std::unique_ptr<ImplScrollBarData> mpData; + long mnStartPos; + long mnMouseOff; + long mnThumbPixRange; + long mnThumbPixPos; + long mnThumbPixSize; + long mnMinRange; + long mnMaxRange; + long mnThumbPos; + long mnVisibleSize; + long mnLineSize; + long mnPageSize; + long mnDelta; + sal_uInt16 mnStateFlags; + ScrollType meScrollType; + bool mbCalcSize; + bool mbFullDrag; + Link<ScrollBar*,void> maScrollHdl; + Link<ScrollBar*,void> maEndScrollHdl; + + SAL_DLLPRIVATE tools::Rectangle* ImplFindPartRect( const Point& rPt ); + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplUpdateRects( bool bUpdate = true ); + SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); + SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); + SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true ); + SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext); + using Window::ImplScroll; + SAL_DLLPRIVATE long ImplScroll( long nNewPos, bool bCallEndScroll ); + SAL_DLLPRIVATE long ImplDoAction( bool bCallEndScroll ); + SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction = true ); + SAL_DLLPRIVATE void ImplInvert(); + SAL_DLLPRIVATE bool ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags); + SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos ); + SAL_DLLPRIVATE Size getCurrentCalcSize() const; + DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, Timer*, void ); + +public: + explicit ScrollBar( vcl::Window* pParent, WinBits nStyle = WB_VERT ); + virtual ~ScrollBar() override; + virtual void dispose() override; + + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void Tracking(const TrackingEvent& rTEvt) override; + virtual void KeyInput(const KeyEvent& rKEvt) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Draw(OutputDevice* pDev, const Point& rPos, DrawFlags nFlags) override; + virtual void Move() override; + virtual void Resize() override; + virtual void StateChanged(StateChangedType nType) override; + virtual void DataChanged(const DataChangedEvent& rDCEvt) override; + virtual bool PreNotify(NotifyEvent& rNEvt) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + using Window::Scroll; + void Scroll(); + virtual void EndScroll(); + + long DoScroll( long nNewPos ); + long DoScrollAction( ScrollType eScrollType ); + + void EnableDrag() { mbFullDrag = true; } + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } + void SetThumbPos( long nThumbPos ); + long GetThumbPos() const { return mnThumbPos; } + void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; } + long GetLineSize() const { return mnLineSize; } + void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; } + long GetPageSize() const { return mnPageSize; } + void SetVisibleSize( long nNewSize ); + long GetVisibleSize() const { return mnVisibleSize; } + + long GetDelta() const { return mnDelta; } + ScrollType GetType() const { return meScrollType; } + + void SetScrollHdl( const Link<ScrollBar*,void>& rLink ) { maScrollHdl = rLink; } + const Link<ScrollBar*,void>& GetScrollHdl() const { return maScrollHdl; } + void SetEndScrollHdl( const Link<ScrollBar*,void>& rLink ) { maEndScrollHdl = rLink; } + + virtual Size GetOptimalSize() const override; +}; + + +class VCL_DLLPUBLIC ScrollBarBox final : public vcl::Window +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + explicit ScrollBarBox( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; +}; + +#endif // INCLUDED_VCL_SCRBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/seleng.hxx b/include/vcl/seleng.hxx new file mode 100644 index 000000000..92c69d147 --- /dev/null +++ b/include/vcl/seleng.hxx @@ -0,0 +1,229 @@ +/* -*- 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_SELENG_HXX +#define INCLUDED_VCL_SELENG_HXX + +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <vcl/event.hxx> +#include <vcl/vclenum.hxx> +#include <o3tl/typed_flags_set.hxx> + +class CommandEvent; + +// Timerticks +#define SELENG_DRAGDROP_TIMEOUT 400 +#define SELENG_AUTOREPEAT_INTERVAL 50 +#define SELENG_AUTOREPEAT_INTERVAL_MIN 25 +#define SELENG_AUTOREPEAT_INTERVAL_MAX 300 + +class VCL_DLLPUBLIC FunctionSet +{ +public: + virtual ~FunctionSet() = 0; + + virtual void BeginDrag() = 0; + + virtual void CreateAnchor() = 0; // Anker-Pos := Cursor-Pos + virtual void DestroyAnchor() = 0; + + // move cursor, at the same time match cursor position to the selection + // starting at anchor. true == Ok + virtual void SetCursorAtPoint( const Point& rPointPixel, + bool bDontSelectAtCursor = false ) = 0; + + virtual bool IsSelectionAtPoint( const Point& rPointPixel ) = 0; + virtual void DeselectAtPoint( const Point& rPointPixel ) = 0; + // delete anchor & deselect all + virtual void DeselectAll() = 0; +}; + + +enum class SelectionEngineFlags { + DRG_ENAB = 0x0001, + IN_SEL = 0x0002, + IN_ADD = 0x0004, + ADD_ALW = 0x0008, + HAS_ANCH = 0x0020, + CMDEVT = 0x0040, + WAIT_UPEVT = 0x0080, + EXPANDONMOVE = 0x0100, +}; +namespace o3tl +{ + template<> struct typed_flags<SelectionEngineFlags> : is_typed_flags<SelectionEngineFlags, 0x01ef> {}; +} + +class VCL_DLLPUBLIC SelectionEngine +{ +private: + FunctionSet* pFunctionSet; + VclPtr<vcl::Window> pWin; + tools::Rectangle aArea; + Timer aWTimer; // generate fake mouse moves + MouseEvent aLastMove; + SelectionMode eSelMode; + sal_uLong nUpdateInterval; + sal_uInt16 nLockedMods; + SelectionEngineFlags nFlags; + DECL_DLLPRIVATE_LINK( ImpWatchDog, Timer*, void ); + + inline bool ShouldDeselect( bool bModifierKey1 ) const; + // determines to deselect or not when Ctrl-key is pressed on CursorPosChanging +public: + + SelectionEngine( vcl::Window* pWindow, + FunctionSet* pFunctions = nullptr ); + ~SelectionEngine(); + + // true: Event was processed by Selection Engine + bool SelMouseButtonDown( const MouseEvent& rMEvt ); + bool SelMouseButtonUp( const MouseEvent& rMEvt ); + bool SelMouseMove( const MouseEvent& rMEvt ); + //SelMouseButtonDown captures mouse events, SelMouseButtonUp + //releases the capture. If you need to release the mouse + //capture after SelMouseButtonDown but before + //SelMouseButtonUp, e.g. to allow events to go to a + //context menu via "Command" which is delivered after + //mouse down but before mouse up, then use this + void ReleaseMouse(); + void CaptureMouse(); + + // Keyboard + void CursorPosChanging( bool bShift, bool bMod1 ); + + // is needed to generate a Move event via a Timer + // when the mouse is outside the area + void SetVisibleArea( const tools::Rectangle& rNewArea ) + { aArea = rNewArea; } + + void SetAddMode( bool); + bool IsAddMode() const; + + void AddAlways( bool bOn ); + bool IsAlwaysAdding() const; + + void EnableDrag( bool bOn ); + + void SetSelectionMode( SelectionMode eMode ); + SelectionMode GetSelectionMode() const { return eSelMode; } + + void SetFunctionSet( FunctionSet* pFuncs ) + { pFunctionSet = pFuncs; } + const FunctionSet* GetFunctionSet() const { return pFunctionSet; } + + const Point& GetMousePosPixel() const + { return aLastMove.GetPosPixel(); } + const MouseEvent& GetMouseEvent() const { return aLastMove; } + + void SetWindow( vcl::Window*); + vcl::Window* GetWindow() const { return pWin; } + + void LockModifiers( sal_uInt16 nModifiers ) + { nLockedMods = nModifiers; } + sal_uInt16 GetLockedModifiers() const { return nLockedMods; } + + bool IsInSelection() const; + void Reset(); + + void Command( const CommandEvent& rCEvt ); + + bool HasAnchor() const; + void SetAnchor( bool bAnchor ); + + void SetUpdateInterval( sal_uLong nInterval ); + + // is switched on in the Ctor + void ExpandSelectionOnMouseMove( bool bExpand = true ) + { + if( bExpand ) + nFlags |= SelectionEngineFlags::EXPANDONMOVE; + else + nFlags &= ~SelectionEngineFlags::EXPANDONMOVE; + } +}; + +inline bool SelectionEngine::IsAddMode() const +{ + if ( nFlags & (SelectionEngineFlags::IN_ADD | SelectionEngineFlags::ADD_ALW) ) + return true; + else + return false; +} + +inline void SelectionEngine::SetAddMode( bool bNewMode ) +{ + if ( bNewMode ) + nFlags |= SelectionEngineFlags::IN_ADD; + else + nFlags &= ~SelectionEngineFlags::IN_ADD; +} + +inline void SelectionEngine::EnableDrag( bool bOn ) +{ + if ( bOn ) + nFlags |= SelectionEngineFlags::DRG_ENAB; + else + nFlags &= ~SelectionEngineFlags::DRG_ENAB; +} + +inline void SelectionEngine::AddAlways( bool bOn ) +{ + if( bOn ) + nFlags |= SelectionEngineFlags::ADD_ALW; + else + nFlags &= ~SelectionEngineFlags::ADD_ALW; +} + +inline bool SelectionEngine::IsAlwaysAdding() const +{ + if ( nFlags & SelectionEngineFlags::ADD_ALW ) + return true; + else + return false; +} + +inline bool SelectionEngine::IsInSelection() const +{ + if ( nFlags & SelectionEngineFlags::IN_SEL ) + return true; + else + return false; +} + +inline bool SelectionEngine::HasAnchor() const +{ + if ( nFlags & SelectionEngineFlags::HAS_ANCH ) + return true; + else + return false; +} + +inline void SelectionEngine::SetAnchor( bool bAnchor ) +{ + if ( bAnchor ) + nFlags |= SelectionEngineFlags::HAS_ANCH; + else + nFlags &= ~SelectionEngineFlags::HAS_ANCH; +} + +#endif // INCLUDED_VCL_SELENG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx new file mode 100644 index 000000000..8e2dd05ab --- /dev/null +++ b/include/vcl/settings.hxx @@ -0,0 +1,729 @@ +/* -*- 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_SETTINGS_HXX +#define INCLUDED_VCL_SETTINGS_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <memory> +#include <vector> + +#include <optional> + +class BitmapEx; +class LanguageTag; +class SvtSysLocale; + +class LocaleDataWrapper; +struct ImplMouseData; +struct ImplMiscData; +struct ImplHelpData; +struct ImplStyleData; +struct ImplAllSettingsData; +enum class ConfigurationHints; + +namespace vcl { + class Font; + class I18nHelper; + class IconThemeInfo; +} + + +enum class MouseSettingsOptions +{ + NONE = 0x00, + AutoFocus = 0x01, + AutoCenterPos = 0x02, + AutoDefBtnPos = 0x04, +}; +namespace o3tl +{ + template<> struct typed_flags<MouseSettingsOptions> : is_typed_flags<MouseSettingsOptions, 0x07> {}; +} + +enum class MouseFollowFlags +{ + Menu = 0x0001, + DDList = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags<MouseFollowFlags> : is_typed_flags<MouseFollowFlags, 0x03> {}; +} + +enum class MouseMiddleButtonAction +{ + Nothing, AutoScroll, PasteSelection +}; + +enum class MouseWheelBehaviour +{ + Disable, FocusOnly, ALWAYS +}; + +class VCL_DLLPUBLIC MouseSettings +{ +private: + void CopyData(); + std::shared_ptr<ImplMouseData> mxData; + +public: + MouseSettings(); + + void SetOptions( MouseSettingsOptions nOptions ); + MouseSettingsOptions GetOptions() const; + + void SetDoubleClickTime( sal_uInt64 nDoubleClkTime ); + sal_uInt64 GetDoubleClickTime() const; + + void SetDoubleClickWidth( long nDoubleClkWidth ); + long GetDoubleClickWidth() const; + + void SetDoubleClickHeight( long nDoubleClkHeight ); + long GetDoubleClickHeight() const; + + void SetStartDragWidth( long nDragWidth ); + long GetStartDragWidth() const; + + void SetStartDragHeight( long nDragHeight ); + long GetStartDragHeight() const; + + static sal_uInt16 GetStartDragCode(); + + static sal_uInt16 GetContextMenuCode(); + + static sal_uInt16 GetContextMenuClicks(); + + static sal_uLong GetScrollRepeat(); + + static sal_uLong GetButtonStartRepeat(); + + void SetButtonRepeat( sal_uLong nRepeat ); + sal_uLong GetButtonRepeat() const; + + static sal_uLong GetActionDelay(); + + void SetMenuDelay( sal_uLong nDelay ); + sal_uLong GetMenuDelay() const; + + void SetFollow( MouseFollowFlags nFollow ); + MouseFollowFlags GetFollow() const; + + void SetMiddleButtonAction( MouseMiddleButtonAction nAction ); + MouseMiddleButtonAction GetMiddleButtonAction() const; + + void SetWheelBehavior( MouseWheelBehaviour nBehavior ); + MouseWheelBehaviour GetWheelBehavior() const; + + bool operator ==( const MouseSettings& rSet ) const; + bool operator !=( const MouseSettings& rSet ) const; +}; + +struct DialogStyle +{ + int content_area_border; + int button_spacing; + int action_area_border; + DialogStyle() + : content_area_border(2) + , button_spacing(6) + , action_area_border(5) + {} +}; + +enum class StyleSettingsOptions +{ + NONE = 0x0000, + Mono = 0x0001, + NoMnemonics = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags<StyleSettingsOptions> : is_typed_flags<StyleSettingsOptions, 0x0003> {}; +} + +enum class DragFullOptions +{ + NONE = 0x0000, + WindowMove = 0x0001, + WindowSize = 0x0002, + Docking = 0x0010, + Split = 0x0020, + Scroll = 0x0040, + All = WindowMove | WindowSize | Docking | Split | Scroll, +}; +namespace o3tl +{ + template<> struct typed_flags<DragFullOptions> : is_typed_flags<DragFullOptions, 0x0073> {}; +} + +enum class SelectionOptions +{ + NONE = 0x0000, + Focus = 0x0001, + Invert = 0x0002, + ShowFirst = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags<SelectionOptions> : is_typed_flags<SelectionOptions, 0x0007> {}; +} + +enum class DisplayOptions +{ + NONE = 0x0000, + AADisable = 0x0001, +}; +namespace o3tl +{ + template<> struct typed_flags<DisplayOptions> : is_typed_flags<DisplayOptions, 0x0001> {}; +} + +enum class ToolbarIconSize +{ + Unknown = 0, + Small = 1, // unused + Large = 2, + Size32 = 3, +}; + +#define STYLE_CURSOR_NOBLINKTIME SAL_MAX_UINT64 + +class VCL_DLLPUBLIC StyleSettings +{ + void CopyData(); + +private: + std::shared_ptr<ImplStyleData> mxData; + +public: + StyleSettings(); + + void Set3DColors( const Color& rColor ); + + void SetFaceColor( const Color& rColor ); + const Color& GetFaceColor() const; + + Color GetFaceGradientColor() const; + + Color GetSeparatorColor() const; + + void SetCheckedColor( const Color& rColor ); + void SetCheckedColorSpecialCase( ); + const Color& GetCheckedColor() const; + + void SetLightColor( const Color& rColor ); + const Color& GetLightColor() const; + + void SetLightBorderColor( const Color& rColor ); + const Color& GetLightBorderColor() const; + + void SetShadowColor( const Color& rColor ); + const Color& GetShadowColor() const; + + void SetDarkShadowColor( const Color& rColor ); + const Color& GetDarkShadowColor() const; + + void SetDefaultButtonTextColor( const Color& rColor ); + const Color& GetDefaultButtonTextColor() const; + + void SetButtonTextColor( const Color& rColor ); + const Color& GetButtonTextColor() const; + + void SetDefaultActionButtonTextColor( const Color& rColor ); + const Color& GetDefaultActionButtonTextColor() const; + + void SetActionButtonTextColor( const Color& rColor ); + const Color& GetActionButtonTextColor() const; + + void SetFlatButtonTextColor( const Color& rColor ); + const Color& GetFlatButtonTextColor() const; + + void SetDefaultButtonRolloverTextColor( const Color& rColor ); + const Color& GetDefaultButtonRolloverTextColor() const; + + void SetButtonRolloverTextColor( const Color& rColor ); + const Color& GetButtonRolloverTextColor() const; + + void SetDefaultActionButtonRolloverTextColor( const Color& rColor ); + const Color& GetDefaultActionButtonRolloverTextColor() const; + + void SetActionButtonRolloverTextColor( const Color& rColor ); + const Color& GetActionButtonRolloverTextColor() const; + + void SetFlatButtonRolloverTextColor( const Color& rColor ); + const Color& GetFlatButtonRolloverTextColor() const; + + void SetDefaultButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetDefaultButtonPressedRolloverTextColor() const; + + void SetButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetButtonPressedRolloverTextColor() const; + + void SetDefaultActionButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetDefaultActionButtonPressedRolloverTextColor() const; + + void SetActionButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetActionButtonPressedRolloverTextColor() const; + + void SetFlatButtonPressedRolloverTextColor( const Color& rColor ); + const Color& GetFlatButtonPressedRolloverTextColor() const; + + void SetRadioCheckTextColor( const Color& rColor ); + const Color& GetRadioCheckTextColor() const; + + void SetGroupTextColor( const Color& rColor ); + const Color& GetGroupTextColor() const; + + void SetLabelTextColor( const Color& rColor ); + const Color& GetLabelTextColor() const; + + void SetWindowColor( const Color& rColor ); + const Color& GetWindowColor() const; + + void SetWindowTextColor( const Color& rColor ); + const Color& GetWindowTextColor() const; + + void SetDialogColor( const Color& rColor ); + const Color& GetDialogColor() const; + + void SetDialogTextColor( const Color& rColor ); + const Color& GetDialogTextColor() const; + + void SetWorkspaceColor( const Color& rColor ); + const Color& GetWorkspaceColor() const; + + void SetFieldColor( const Color& rColor ); + const Color& GetFieldColor() const; + + void SetFieldTextColor( const Color& rColor ); + const Color& GetFieldTextColor() const; + + void SetFieldRolloverTextColor( const Color& rColor ); + const Color& GetFieldRolloverTextColor() const; + + void SetActiveColor( const Color& rColor ); + const Color& GetActiveColor() const; + + void SetActiveTextColor( const Color& rColor ); + const Color& GetActiveTextColor() const; + + void SetActiveBorderColor( const Color& rColor ); + const Color& GetActiveBorderColor() const; + + void SetDeactiveColor( const Color& rColor ); + const Color& GetDeactiveColor() const; + + void SetDeactiveTextColor( const Color& rColor ); + const Color& GetDeactiveTextColor() const; + + void SetDeactiveBorderColor( const Color& rColor ); + const Color& GetDeactiveBorderColor() const; + + void SetHighlightColor( const Color& rColor ); + const Color& GetHighlightColor() const; + + void SetHighlightTextColor( const Color& rColor ); + const Color& GetHighlightTextColor() const; + + void SetDisableColor( const Color& rColor ); + const Color& GetDisableColor() const; + + void SetHelpColor( const Color& rColor ); + const Color& GetHelpColor() const; + + void SetHelpTextColor( const Color& rColor ); + const Color& GetHelpTextColor() const; + + void SetMenuColor( const Color& rColor ); + const Color& GetMenuColor() const; + + void SetMenuBarColor( const Color& rColor ); + const Color& GetMenuBarColor() const; + + void SetMenuBarRolloverColor( const Color& rColor ); + const Color& GetMenuBarRolloverColor() const; + + void SetMenuBorderColor( const Color& rColor ); + const Color& GetMenuBorderColor() const; + + void SetMenuTextColor( const Color& rColor ); + const Color& GetMenuTextColor() const; + + void SetMenuBarTextColor( const Color& rColor ); + const Color& GetMenuBarTextColor() const; + + void SetMenuBarRolloverTextColor( const Color& rColor ); + const Color& GetMenuBarRolloverTextColor() const; + + void SetMenuBarHighlightTextColor( const Color& rColor ); + const Color& GetMenuBarHighlightTextColor() const; + + void SetMenuHighlightColor( const Color& rColor ); + const Color& GetMenuHighlightColor() const; + + void SetMenuHighlightTextColor( const Color& rColor ); + const Color& GetMenuHighlightTextColor() const; + + void SetTabTextColor( const Color& rColor ); + const Color& GetTabTextColor() const; + + void SetTabRolloverTextColor( const Color& rColor ); + const Color& GetTabRolloverTextColor() const; + + void SetTabHighlightTextColor( const Color& rColor ); + const Color& GetTabHighlightTextColor() const; + + void SetToolTextColor( const Color& rColor ); + const Color& GetToolTextColor() const; + + void SetLinkColor( const Color& rColor ); + const Color& GetLinkColor() const; + + void SetVisitedLinkColor( const Color& rColor ); + const Color& GetVisitedLinkColor() const; + + const Color& GetHighlightLinkColor() const; + + void SetMonoColor( const Color& rColor ); + const Color& GetMonoColor() const; + + void SetActiveTabColor( const Color& rColor ); + const Color& GetActiveTabColor() const; + + void SetInactiveTabColor( const Color& rColor ); + const Color& GetInactiveTabColor() const; + + void SetAlternatingRowColor(const Color& rColor); + const Color& GetAlternatingRowColor() const; + + void SetHighContrastMode(bool bHighContrast ); + bool GetHighContrastMode() const; + + void SetUseSystemUIFonts( bool bUseSystemUIFonts ); + bool GetUseSystemUIFonts() const; + + void SetUseFontAAFromSystem(bool bUseFontAAFromSystem); + bool GetUseFontAAFromSystem() const; + + void SetUseFlatBorders( bool bUseFlatBorders ); + bool GetUseFlatBorders() const; + + void SetUseFlatMenus( bool bUseFlatMenus ); + bool GetUseFlatMenus() const; + + void SetUseImagesInMenus( TriState eUseImagesInMenus ); + bool GetUseImagesInMenus() const; + + void SetPreferredUseImagesInMenus( bool bPreferredUseImagesInMenus ); + bool GetPreferredUseImagesInMenus() const; + + void SetSkipDisabledInMenus( bool bSkipDisabledInMenus ); + bool GetSkipDisabledInMenus() const; + + void SetHideDisabledMenuItems( bool bHideDisabledMenuItems ); + bool GetHideDisabledMenuItems() const; + + void SetContextMenuShortcuts( TriState eContextMenuShortcuts ); + bool GetContextMenuShortcuts() const; + + void SetPreferredContextMenuShortcuts( bool bContextMenuShortcuts ); + bool GetPreferredContextMenuShortcuts() const; + + void SetPrimaryButtonWarpsSlider( bool bPrimaryButtonWarpsSlider ); + bool GetPrimaryButtonWarpsSlider() const; + + void SetAppFont( const vcl::Font& rFont ); + const vcl::Font& GetAppFont() const; + + void SetHelpFont( const vcl::Font& rFont ); + const vcl::Font& GetHelpFont() const; + + void SetTitleFont( const vcl::Font& rFont ); + const vcl::Font& GetTitleFont() const; + + void SetFloatTitleFont( const vcl::Font& rFont ); + const vcl::Font& GetFloatTitleFont() const; + + void SetMenuFont( const vcl::Font& rFont ); + const vcl::Font& GetMenuFont() const; + + void SetToolFont( const vcl::Font& rFont ); + const vcl::Font& GetToolFont() const; + + void SetGroupFont( const vcl::Font& rFont ); + const vcl::Font& GetGroupFont() const; + + void SetLabelFont( const vcl::Font& rFont ); + const vcl::Font& GetLabelFont() const; + + void SetRadioCheckFont( const vcl::Font& rFont ); + const vcl::Font& GetRadioCheckFont() const; + + void SetPushButtonFont( const vcl::Font& rFont ); + const vcl::Font& GetPushButtonFont() const; + + void SetFieldFont( const vcl::Font& rFont ); + const vcl::Font& GetFieldFont() const; + + void SetIconFont( const vcl::Font& rFont ); + const vcl::Font& GetIconFont() const; + + void SetTabFont( const vcl::Font& rFont ); + const vcl::Font& GetTabFont() const; + + static long GetBorderSize(); + + void SetTitleHeight( long nSize ); + long GetTitleHeight() const; + + void SetFloatTitleHeight( long nSize ); + long GetFloatTitleHeight() const; + + void SetScrollBarSize( long nSize ); + long GetScrollBarSize() const; + + void SetMinThumbSize( long nSize ); + long GetMinThumbSize() const; + + void SetSpinSize( long nSize ); + long GetSpinSize() const; + + static long GetSplitSize(); + + void SetCursorSize( long nSize ); + long GetCursorSize() const; + + void SetCursorBlinkTime( sal_uInt64 nBlinkTime ); + sal_uInt64 GetCursorBlinkTime() const; + + void SetDragFullOptions( DragFullOptions nOptions ); + DragFullOptions GetDragFullOptions() const; + + void SetSelectionOptions( SelectionOptions nOptions ); + SelectionOptions GetSelectionOptions() const; + + void SetDisplayOptions( DisplayOptions nOptions ); + DisplayOptions GetDisplayOptions() const; + + void SetAntialiasingMinPixelHeight( long nMinPixel ); + sal_uLong GetAntialiasingMinPixelHeight() const; + + void SetOptions( StyleSettingsOptions nOptions ); + StyleSettingsOptions GetOptions() const; + + void SetAutoMnemonic( bool bAutoMnemonic ); + bool GetAutoMnemonic() const; + + static bool GetDockingFloatsSupported(); + + void SetFontColor( const Color& rColor ); + const Color& GetFontColor() const; + + void SetToolbarIconSize( ToolbarIconSize nSize ); + ToolbarIconSize GetToolbarIconSize() const; + + /** Set the icon theme to use. */ + void SetIconTheme(const OUString&); + + /** Determine which icon theme should be used. + * + * This might not be the same as the one which has been set with SetIconTheme(), + * e.g., if high contrast mode is enabled. + * + * (for the detailed logic @see vcl::IconThemeSelector) + */ + OUString DetermineIconTheme() const; + + /** Obtain the list of icon themes which were found in the config folder + * @see vcl::IconThemeScanner for more details. + */ + std::vector<vcl::IconThemeInfo> const & GetInstalledIconThemes() const; + + /** Obtain the name of the icon theme which will be chosen automatically for the desktop environment. + * This method will only return icon themes which were actually found on the system. + */ + OUString GetAutomaticallyChosenIconTheme() const; + + /** Set a preferred icon theme. + * This theme will be preferred in GetAutomaticallyChosenIconTheme() + */ + void SetPreferredIconTheme(const OUString&, bool bDarkIconTheme = false); + + const DialogStyle& GetDialogStyle() const; + + BitmapEx const & GetPersonaHeader() const; + + BitmapEx const & GetPersonaFooter() const; + + const std::optional<Color>& GetPersonaMenuBarTextColor() const; + + // global switch to allow EdgeBlenging; currently possible for ValueSet and ListBox + // when activated there using Get/SetEdgeBlending; default is true + void SetEdgeBlending(sal_uInt16 nCount); + sal_uInt16 GetEdgeBlending() const; + + // TopLeft (default Color(0xC0, 0xC0, 0xC0)) and BottomRight (default Color(0x40, 0x40, 0x40)) + // default colors for EdgeBlending + const Color& GetEdgeBlendingTopLeftColor() const; + const Color& GetEdgeBlendingBottomRightColor() const; + + // maximum line count for ListBox control; to use this, call AdaptDropDownLineCountToMaximum() at the + // ListBox after it's ItemCount has changed/got filled. Default is 25. If more Items exist, a scrollbar + // will be used + void SetListBoxMaximumLineCount(sal_uInt16 nCount); + sal_uInt16 GetListBoxMaximumLineCount() const; + + // maximum column count for the ColorValueSet control. Default is 12 and this is optimized for the + // color scheme which has 12-color aligned layout for the part taken over from Symphony. Do + // only change this if you know what you are doing. + void SetColorValueSetColumnCount(sal_uInt16 nCount); + sal_uInt16 GetColorValueSetColumnCount() const; + + // maximum row/line count for the ColorValueSet control. If more lines would be needed, a scrollbar will + // be used. + static sal_uInt16 GetColorValueSetMaximumRowCount(); + + void SetListBoxPreviewDefaultLogicSize(Size const & rSize); + const Size& GetListBoxPreviewDefaultPixelSize() const; + + // the default LineWidth for ListBox UI previews (LineStyle, LineDash, LineStartEnd). Default is 1. + static sal_uInt16 GetListBoxPreviewDefaultLineWidth(); + + // defines if previews which contain potentially transparent objects (e.g. the dash/line/LineStartEnd previews and others) + // use the default transparent visualization background (checkered background) as it has got standard in graphic programs nowadays + void SetPreviewUsesCheckeredBackground(bool bNew); + bool GetPreviewUsesCheckeredBackground() const; + + void SetStandardStyles(); + + bool operator ==( const StyleSettings& rSet ) const; + bool operator !=( const StyleSettings& rSet ) const; + + // Batch setters used by various backends + void BatchSetBackgrounds( const Color &aBackColor, + bool bCheckedColorSpecialCase = true ); + void BatchSetFonts( const vcl::Font& aAppFont, + const vcl::Font& aLabelFont ); +}; + + +class VCL_DLLPUBLIC MiscSettings +{ + std::shared_ptr<ImplMiscData> mxData; + +public: + MiscSettings(); + +#ifdef _WIN32 + void SetEnableATToolSupport( bool bEnable ); +#endif + bool GetEnableATToolSupport() const; + bool GetDisablePrinting() const; + void SetEnableLocalizedDecimalSep( bool bEnable ); + bool GetEnableLocalizedDecimalSep() const; + + bool operator ==( const MiscSettings& rSet ) const; + bool operator !=( const MiscSettings& rSet ) const; +}; + + +class VCL_DLLPUBLIC HelpSettings +{ + std::shared_ptr<ImplHelpData> mxData; + +public: + HelpSettings(); + + static sal_uLong GetTipDelay(); + void SetTipTimeout( sal_uLong nTipTimeout ); + sal_uLong GetTipTimeout() const; + static sal_uLong GetBalloonDelay(); + + bool operator ==( const HelpSettings& rSet ) const; + bool operator !=( const HelpSettings& rSet ) const; +}; + + +enum class AllSettingsFlags { + NONE = 0x0000, + MOUSE = 0x0001, + STYLE = 0x0002, + MISC = 0x0004, + LOCALE = 0x0020, +}; +namespace o3tl +{ + template<> struct typed_flags<AllSettingsFlags> : is_typed_flags<AllSettingsFlags, 0x0027> {}; +} + +class VCL_DLLPUBLIC AllSettings +{ +private: + void CopyData(); + + std::shared_ptr<ImplAllSettingsData> mxData; + +public: + AllSettings(); + + void SetMouseSettings( const MouseSettings& rSet ); + const MouseSettings& GetMouseSettings() const; + + void SetStyleSettings( const StyleSettings& rSet ); + const StyleSettings& GetStyleSettings() const; + + void SetMiscSettings( const MiscSettings& rSet ); + const MiscSettings& GetMiscSettings() const; + + void SetHelpSettings( const HelpSettings& rSet ); + const HelpSettings& GetHelpSettings() const; + + void SetLanguageTag(const OUString& rLanguage, bool bCanonicalize); + void SetLanguageTag( const LanguageTag& rLanguageTag ); + const LanguageTag& GetLanguageTag() const; + const LanguageTag& GetUILanguageTag() const; + static bool GetLayoutRTL(); // returns true if UI language requires right-to-left Text Layout + static bool GetMathLayoutRTL(); // returns true if UI language requires right-to-left Math Layout + const LocaleDataWrapper& GetLocaleDataWrapper() const; + const LocaleDataWrapper& GetUILocaleDataWrapper() const; + const LocaleDataWrapper& GetNeutralLocaleDataWrapper() const; + const vcl::I18nHelper& GetLocaleI18nHelper() const; + const vcl::I18nHelper& GetUILocaleI18nHelper() const; + + static AllSettingsFlags GetWindowUpdate() + { return AllSettingsFlags::MOUSE | AllSettingsFlags::STYLE | AllSettingsFlags::MISC | AllSettingsFlags::LOCALE; } + + AllSettingsFlags Update( AllSettingsFlags nFlags, const AllSettings& rSettings ); + AllSettingsFlags GetChangeFlags( const AllSettings& rSettings ) const; + + bool operator ==( const AllSettings& rSet ) const; + bool operator !=( const AllSettings& rSet ) const; + static void LocaleSettingsChanged( ConfigurationHints nHint ); + SvtSysLocale& GetSysLocale(); +}; + +#endif // INCLUDED_VCL_SETTINGS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/skia/SkiaHelper.hxx b/include/vcl/skia/SkiaHelper.hxx new file mode 100644 index 000000000..8cb76c653 --- /dev/null +++ b/include/vcl/skia/SkiaHelper.hxx @@ -0,0 +1,41 @@ +/* -*- 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_SKIA_SKIAHELPER_HXX +#define INCLUDED_VCL_SKIA_SKIAHELPER_HXX + +#include <vcl/dllapi.h> + +#include <config_features.h> + +namespace SkiaHelper +{ +VCL_DLLPUBLIC bool isVCLSkiaEnabled(); + +#if HAVE_FEATURE_SKIA + +// Which Skia backend to use. +enum RenderMethod +{ + RenderRaster, + RenderVulkan +}; + +VCL_DLLPUBLIC RenderMethod renderMethodToUse(); + +// Clean up before exit. +VCL_DLLPUBLIC void cleanup(); + +#endif // HAVE_FEATURE_SKIA + +} // namespace + +#endif // INCLUDED_VCL_SKIA_SKIAHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/sound.hxx b/include/vcl/sound.hxx new file mode 100644 index 000000000..2df3c8004 --- /dev/null +++ b/include/vcl/sound.hxx @@ -0,0 +1,31 @@ +/* -*- 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 . + */ + +#pragma once + +#include <vcl/dllapi.h> + + +class VCL_DLLPUBLIC Sound +{ +public: + static void Beep(); +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/specialchars.hxx b/include/vcl/specialchars.hxx new file mode 100644 index 000000000..d310a92a6 --- /dev/null +++ b/include/vcl/specialchars.hxx @@ -0,0 +1,43 @@ +/* -*- 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_SPECIAL_CHARS_HXX +#define INCLUDED_VCL_SPECIAL_CHARS_HXX + +namespace vcl +{ +class Font; +} + +namespace weld +{ +class Widget; +} + +typedef OUString (*FncGetSpecialChars)(weld::Widget* pWin, const vcl::Font& rFont); + +namespace vcl +{ +void VCL_DLLPUBLIC SetGetSpecialCharsFunction(FncGetSpecialChars fn); +FncGetSpecialChars VCL_DLLPUBLIC GetGetSpecialCharsFunction(); +}; + +#endif // INCLUDED_VCL_SPECIAL_CHARS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/spinfld.hxx b/include/vcl/spinfld.hxx new file mode 100644 index 000000000..7ef61be4a --- /dev/null +++ b/include/vcl/spinfld.hxx @@ -0,0 +1,98 @@ +/* -*- 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_SPINFLD_HXX +#define INCLUDED_VCL_SPINFLD_HXX + +#include <vcl/dllapi.h> +#include <vcl/edit.hxx> +#include <vcl/timer.hxx> +#include <config_options.h> + + +class VCL_DLLPUBLIC SpinField : public Edit +{ +public: + explicit SpinField( vcl::Window* pParent, WinBits nWinStyle, WindowType nType = WindowType::SPINFIELD ); + virtual ~SpinField() override; + virtual void dispose() override; + + virtual bool ShowDropDown( bool bShow ); + + virtual void Up(); + virtual void Down(); + virtual void First(); + virtual void Last(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + void SetUpHdl( const Link<SpinField&,void>& rLink ) { maUpHdlLink = rLink; } + void SetDownHdl( const Link<SpinField&,void>& rLink ) { maDownHdlLink = rLink; } + + virtual Size CalcMinimumSize() const override; + virtual Size CalcMinimumSizeForText(const OUString &rString) const override; + virtual Size GetOptimalSize() const override; + virtual Size CalcSize(sal_Int32 nChars) const override; + + virtual FactoryFunction GetUITestFactory() const override; + +protected: + tools::Rectangle maUpperRect; + tools::Rectangle maLowerRect; + tools::Rectangle maDropDownRect; // not yet attached ... + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + + void EndDropDown(); + + virtual void FillLayoutData() const override; + tools::Rectangle * ImplFindPartRect( const Point& rPt ); + +private: + DECL_DLLPRIVATE_LINK( ImplTimeout, Timer*, void ); + SAL_DLLPRIVATE void ImplInitSpinFieldData(); + SAL_DLLPRIVATE void ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, tools::Rectangle& rDDArea, tools::Rectangle& rSpinUpArea, tools::Rectangle& rSpinDownArea ); + + VclPtr<Edit> mpEdit; + AutoTimer maRepeatTimer; + Link<SpinField&,void> maUpHdlLink; + Link<SpinField&,void> maDownHdlLink; + bool mbRepeat:1, + mbSpin:1, + mbInitialUp:1, + mbInitialDown:1, + mbUpperIn:1, + mbLowerIn:1, + mbInDropDown:1; +}; + +#endif // INCLUDED_VCL_SPINFLD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/split.hxx b/include/vcl/split.hxx new file mode 100644 index 000000000..fcc2fb182 --- /dev/null +++ b/include/vcl/split.hxx @@ -0,0 +1,105 @@ +/* -*- 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_SPLIT_HXX +#define INCLUDED_VCL_SPLIT_HXX + +#include <vcl/dllapi.h> +#include <vcl/keycod.hxx> +#include <vcl/window.hxx> + +#define SPLITTER_DEFAULTSTEPSIZE 0xFFFF + +class VCL_DLLPUBLIC Splitter : public vcl::Window +{ +private: + VclPtr<vcl::Window> mpRefWin; + long mnSplitPos; + long mnLastSplitPos; + long mnStartSplitPos; + Point maDragPos; + tools::Rectangle maDragRect; + bool mbHorzSplit; + bool mbDragFull; + bool mbKbdSplitting; + bool mbInKeyEvent; + long mnKeyboardStepSize; + Link<Splitter*,void> maStartSplitHdl; + Link<Splitter*,void> maSplitHdl; + Link<Splitter*,void> maEndSplitHdl; + + SAL_DLLPRIVATE void ImplDrawSplitter(); + SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos ); + SAL_DLLPRIVATE void ImplStartKbdSplitting(); + SAL_DLLPRIVATE void ImplKbdTracking( vcl::KeyCode aKeyCode ); + SAL_DLLPRIVATE bool ImplSplitterActive(); + SAL_DLLPRIVATE Splitter* ImplFindSibling(); + SAL_DLLPRIVATE void ImplRestoreSplitter(); + SAL_DLLPRIVATE void ImplInitHorVer(bool bNew); + + Splitter (const Splitter &) = delete; + Splitter& operator= (const Splitter &) = delete; + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nWinStyle ); + +public: + explicit Splitter( vcl::Window* pParent, WinBits nStyle = WB_VSCROLL ); + virtual ~Splitter() override; + virtual void dispose() override; + + void StartSplit(); + void EndSplit(); + void Split(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rPaintRect ) override; + virtual Size GetOptimalSize() const override; + + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void StartDrag(); + + void SetDragRectPixel( const tools::Rectangle& rDragRect, + vcl::Window* pRefWin = nullptr ); + + void SetSplitPosPixel( long nPos ); + long GetSplitPosPixel() const { return mnSplitPos; } + + bool IsHorizontal() const { return mbHorzSplit; } + void SetHorizontal(bool bNew); + + // set the stepsize of the splitter for cursor movement + // the default is 10% of the reference window's width/height + void SetKeyboardStepSize( long nStepSize ); + + void SetStartSplitHdl( const Link<Splitter*,void>& rLink ) { maStartSplitHdl = rLink; } + void SetSplitHdl( const Link<Splitter*,void>& rLink ) { maSplitHdl = rLink; } + void SetEndSplitHdl( const Link<Splitter*,void>& rLink ) { maEndSplitHdl = rLink; } +}; + +#endif // INCLUDED_VCL_SPLIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/splitwin.hxx b/include/vcl/splitwin.hxx new file mode 100644 index 000000000..fcec64ef7 --- /dev/null +++ b/include/vcl/splitwin.hxx @@ -0,0 +1,184 @@ +/* -*- 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_SPLITWIN_HXX +#define INCLUDED_VCL_SPLITWIN_HXX + +#include <vcl/dllapi.h> +#include <vcl/dockwin.hxx> +#include <o3tl/typed_flags_set.hxx> + +class ImplSplitSet; + +enum class SplitWindowItemFlags +{ + NONE = 0x0000, + Fixed = 0x0001, + RelativeSize = 0x0002, + PercentSize = 0x0004, + ColSet = 0x0008, +}; +namespace o3tl +{ + template<> struct typed_flags<SplitWindowItemFlags> : is_typed_flags<SplitWindowItemFlags, 0x0f> {}; +} + +#define SPLITWINDOW_APPEND (sal_uInt16(0xFFFF)) +#define SPLITWINDOW_ITEM_NOTFOUND (sal_uInt16(0xFFFF)) + +class VCL_DLLPUBLIC SplitWindow : public DockingWindow +{ +private: + std::unique_ptr<ImplSplitSet> mpMainSet; + ImplSplitSet* mpBaseSet; + ImplSplitSet* mpSplitSet; + long* mpLastSizes; + tools::Rectangle maDragRect; + long mnDX; + long mnDY; + long mnLeftBorder; + long mnTopBorder; + long mnRightBorder; + long mnBottomBorder; + long mnMaxSize; + long mnMouseOff; + long mnMStartPos; + long mnMSplitPos; + WinBits mnWinStyle; + WindowAlign meAlign; + sal_uInt16 mnSplitTest; + sal_uInt16 mnSplitPos; + sal_uInt16 mnMouseModifier; + bool mbDragFull:1, + mbHorz:1, + mbBottomRight:1, + mbCalc:1, + mbRecalc:1, + mbInvalidate:1, + mbFadeIn:1, + mbFadeOut:1, + mbFadeInDown:1, + mbFadeOutDown:1, + mbFadeInPressed:1, + mbFadeOutPressed:1, + mbFadeNoButtonMode:1; + Link<SplitWindow*,void> maSplitHdl; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplCalcLayout(); + SAL_DLLPRIVATE void ImplUpdate(); + SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta ); + SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos ); + SAL_DLLPRIVATE void ImplGetButtonRect( tools::Rectangle& rRect, bool bTest ) const; + SAL_DLLPRIVATE void ImplGetFadeInRect( tools::Rectangle& rRect, bool bTest = false ) const; + SAL_DLLPRIVATE void ImplGetFadeOutRect( tools::Rectangle& rRect ) const; + SAL_DLLPRIVATE void ImplDrawFadeIn(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawFadeOut(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplNewAlign(); + SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, bool bHorz, bool bLeft); + SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt ); + + SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawBorderLine(vcl::RenderContext& rRenderContext); + static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, bool bHide, + bool bRows ); + static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos, + long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos, + bool bRows ); + static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( const SplitWindow* pWindow, const Point& rPos, + long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos ); + SAL_DLLPRIVATE void ImplDrawSplitTracking(const Point& rPos); + + SplitWindow (const SplitWindow &) = delete; + SplitWindow & operator= (const SplitWindow &) = delete; +public: + SplitWindow( vcl::Window* pParent, WinBits nStyle = 0 ); + virtual ~SplitWindow() override; + virtual void dispose() override; + + virtual void StartSplit(); + virtual void Split(); + virtual void SplitResize(); + virtual void FadeIn(); + virtual void FadeOut(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + void InsertItem( sal_uInt16 nId, vcl::Window* pWindow, long nSize, + sal_uInt16 nPos, sal_uInt16 nIntoSetId, + SplitWindowItemFlags nBits ); + void InsertItem( sal_uInt16 nId, long nSize, + sal_uInt16 nPos, sal_uInt16 nIntoSetId, + SplitWindowItemFlags nBits ); + void RemoveItem( sal_uInt16 nId ); + + void SplitItem( sal_uInt16 nId, long nNewSize, + bool bPropSmall, + bool bPropGreat ); + void SetItemSize( sal_uInt16 nId, long nNewSize ); + long GetItemSize( sal_uInt16 nId ) const; + /** Set a range that limits the (variable part of the) size with an + upper and a lower bound (both are valid values themselves.) + @param nId + Id of the item for which the size limits are set. + @param rRange + Values of -1 define missing bounds, thus setting a range (-1,-1) + (the default) removes the size limit. + */ + void SetItemSizeRange (sal_uInt16 nId, const Range& rRange); + /** Return the current size limits for the specified item. + */ + long GetItemSize( sal_uInt16 nId, SplitWindowItemFlags nBits ) const; + sal_uInt16 GetSet( sal_uInt16 nId ) const; + sal_uInt16 GetItemId( vcl::Window* pWindow ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemCount( sal_uInt16 nSetId = 0 ) const; + bool IsItemValid( sal_uInt16 nId ) const; + + void SetAlign( WindowAlign eNewAlign ); + WindowAlign GetAlign() const { return meAlign; } + bool IsHorizontal() const { return mbHorz; } + + void SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; } + + Size CalcLayoutSizePixel( const Size& aNewSize ); + + void ShowFadeInHideButton(); + void ShowFadeOutButton(); + long GetFadeInSize() const; + bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode; } + + void SetSplitHdl( const Link<SplitWindow*,void>& rLink ) { maSplitHdl = rLink; } +}; + +#endif // INCLUDED_VCL_SPLITWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/status.hxx b/include/vcl/status.hxx new file mode 100644 index 000000000..2700e2a8e --- /dev/null +++ b/include/vcl/status.hxx @@ -0,0 +1,193 @@ +/* -*- 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_STATUS_HXX +#define INCLUDED_VCL_STATUS_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <memory> +#include <vector> + +class DataChangedEvent; +class HelpEvent; +class MouseEvent; +class UserDrawEvent; +struct ImplStatusItem; + +void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos, + long nOffset, long nPrgsWidth, long nPrgsHeight, + sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount, + const tools::Rectangle& rFramePosSize); + + +enum class StatusBarItemBits { + NONE = 0x0000, + Left = 0x0001, + Center = 0x0002, + Right = 0x0004, + In = 0x0008, + Out = 0x0010, + Flat = 0x0020, + AutoSize = 0x0040, + UserDraw = 0x0080, + Mandatory = 0x0100, +}; +namespace o3tl +{ + template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x01ff> {}; +} + +#define STATUSBAR_APPEND (sal_uInt16(0xFFFF)) +#define STATUSBAR_ITEM_NOTFOUND (sal_uInt16(0xFFFF)) +#define STATUSBAR_OFFSET (long(5)) + + +class VCL_DLLPUBLIC StatusBar : public vcl::Window +{ + class SAL_DLLPRIVATE ImplData; +private: + std::vector<std::unique_ptr<ImplStatusItem>> mvItemList; + std::unique_ptr<ImplData> mpImplData; + OUString maPrgsTxt; + Point maPrgsTxtPos; + tools::Rectangle maPrgsFrameRect; + long mnPrgsSize; + long mnItemsWidth; + long mnDX; + long mnDY; + long mnCalcHeight; + long mnTextY; + sal_uInt16 mnCurItemId; + sal_uInt16 mnPercent; + sal_uInt16 mnPercentCount; + sal_uInt32 mnLastProgressPaint_ms; + bool mbFormat; + bool mbProgressMode; + bool mbInUserDraw; + bool mbAdjustHiDPI; + Link<StatusBar*,void> maClickHdl; + Link<StatusBar*,void> maDoubleClickHdl; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE void ImplFormat(); + SAL_DLLPRIVATE bool ImplIsItemUpdate(); + + SAL_DLLPRIVATE void ImplDrawText(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen, + sal_uInt16 nPos); + SAL_DLLPRIVATE void ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc); + SAL_DLLPRIVATE void ImplCalcProgressRect(); + SAL_DLLPRIVATE tools::Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const; + SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisiblePos() const; + +protected: + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + StatusBar( vcl::Window* pParent, + WinBits nWinStyle = WB_BORDER | WB_RIGHT ); + virtual ~StatusBar() override; + virtual void dispose() override; + + void AdjustItemWidthsForHiDPI(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void Click(); + void DoubleClick(); + virtual void UserDraw( const UserDrawEvent& rUDEvt ); + + void InsertItem( sal_uInt16 nItemId, sal_uLong nWidth, + StatusBarItemBits nBits = StatusBarItemBits::Center | StatusBarItemBits::In, + long nOffset = STATUSBAR_OFFSET, + sal_uInt16 nPos = STATUSBAR_APPEND ); + void RemoveItem( sal_uInt16 nItemId ); + + void ShowItem( sal_uInt16 nItemId ); + void HideItem( sal_uInt16 nItemId ); + bool IsItemVisible( sal_uInt16 nItemId ) const; + + void RedrawItem( sal_uInt16 nItemId ); + + void Clear(); + + sal_uInt16 GetItemCount() const; + sal_uInt16 GetItemId( sal_uInt16 nPos ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + sal_uInt16 GetItemPos( sal_uInt16 nItemId ) const; + tools::Rectangle GetItemRect( sal_uInt16 nItemId ) const; + Point GetItemTextPos( sal_uInt16 nItemId ) const; + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + + sal_uLong GetItemWidth( sal_uInt16 nItemId ) const; + StatusBarItemBits GetItemBits( sal_uInt16 nItemId ) const; + + long GetItemOffset( sal_uInt16 nItemId ) const; + + /// @param nCharsWidth, if not -1, overrides the normal width calculation + void SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCharsWidth = -1 ); + const OUString& GetItemText( sal_uInt16 nItemId ) const; + + void SetItemData( sal_uInt16 nItemId, void* pNewData ); + void* GetItemData( sal_uInt16 nItemId ) const; + + void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); + OUString GetItemCommand( sal_uInt16 nItemId ); + + void SetHelpText( sal_uInt16 nItemId, const OUString& rText ); + const OUString& GetHelpText( sal_uInt16 nItemId ) const; + + using Window::SetQuickHelpText; + void SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText ); + using Window::GetQuickHelpText; + const OUString& GetQuickHelpText( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); + + void StartProgressMode( const OUString& rText ); + void SetProgressValue( sal_uInt16 nPercent ); + void EndProgressMode(); + bool IsProgressMode() const { return mbProgressMode; } + + void SetText( const OUString& rText ) override; + + Size CalcWindowSizePixel() const; + + void SetClickHdl( const Link<StatusBar*,void>& rLink ) { maClickHdl = rLink; } + void SetDoubleClickHdl( const Link<StatusBar*,void>& rLink ) { maDoubleClickHdl = rLink; } + + using Window::SetAccessibleName; + void SetAccessibleName( sal_uInt16 nItemId, const OUString& rName ); + using Window::GetAccessibleName; + const OUString& GetAccessibleName( sal_uInt16 nItemId ) const; +}; + +#endif // INCLUDED_VCL_STATUS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/stdtext.hxx b/include/vcl/stdtext.hxx new file mode 100644 index 000000000..c98e4c4c7 --- /dev/null +++ b/include/vcl/stdtext.hxx @@ -0,0 +1,49 @@ +/* -*- 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_STDTEXT_HXX +#define INCLUDED_VCL_STDTEXT_HXX + +#include <rtl/ustring.hxx> +#include <tools/wintypes.hxx> +#include <vcl/dllapi.h> + +class Image; +namespace weld { class Widget; } + +void VCL_DLLPUBLIC ShowServiceNotAvailableError(weld::Widget* pParent, const OUString& rServiceName, bool bError); + +OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton); + +VCL_DLLPUBLIC Image const & GetStandardInfoBoxImage(); +VCL_DLLPUBLIC OUString GetStandardInfoBoxText(); + +VCL_DLLPUBLIC Image const & GetStandardWarningBoxImage(); +VCL_DLLPUBLIC OUString GetStandardWarningBoxText(); + +VCL_DLLPUBLIC Image const & GetStandardErrorBoxImage(); +VCL_DLLPUBLIC OUString GetStandardErrorBoxText(); + +VCL_DLLPUBLIC Image const & GetStandardQueryBoxImage(); +VCL_DLLPUBLIC OUString GetStandardQueryBoxText(); + + +#endif // INCLUDED_VCL_STDTEXT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx new file mode 100644 index 000000000..c73060e9e --- /dev/null +++ b/include/vcl/svapp.hxx @@ -0,0 +1,1450 @@ +/* -*- 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_SVAPP_HXX +#define INCLUDED_VCL_SVAPP_HXX + +#include <sal/config.h> +#include <sal/types.h> + +#include <cassert> +#include <vector> + +#include <comphelper/solarmutex.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> +#include <osl/thread.h> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/inputtypes.hxx> +#include <vcl/exceptiontypes.hxx> +#include <vcl/vclevent.hxx> +#include <vcl/vclenum.hxx> +#include <i18nlangtag/lang.h> +#include <o3tl/typed_flags_set.hxx> +#include <com/sun/star/uno/Reference.h> + + +class BitmapEx; +namespace weld +{ + class Builder; + class MessageDialog; + class Widget; + class Window; +} +class LocaleDataWrapper; +class AllSettings; +class DataChangedEvent; +class Accelerator; +class Help; +class OutputDevice; +namespace vcl { class Window; } +namespace vcl { class KeyCode; } +class NotifyEvent; +class KeyEvent; +class MouseEvent; +class GestureEvent; +struct ImplSVEvent; +struct ConvertData; + +namespace com { +namespace sun { +namespace star { +namespace uno { + class XComponentContext; +} +namespace ui { + namespace dialogs { + class XFilePicker2; + class XFolderPicker2; + } +} +namespace awt { + class XToolkit; + class XDisplayConnection; + class XWindow; +} +} } } + +// helper needed by SalLayout implementations as well as svx/source/dialog/svxbmpnumbalueset.cxx +VCL_DLLPUBLIC sal_UCS4 GetMirroredChar( sal_UCS4 ); +VCL_DLLPUBLIC sal_UCS4 GetLocalizedChar( sal_UCS4, LanguageType ); + +enum class SystemWindowFlags { + NOAUTOMODE = 0x0001, + DIALOG = 0x0002 +}; +namespace o3tl +{ + template<> struct typed_flags<SystemWindowFlags> : is_typed_flags<SystemWindowFlags, 0x03> {}; +} + +typedef long (*VCLEventHookProc)( NotifyEvent& rEvt, void* pData ); + +/** An application can be notified of a number of different events: + - Type::Accept - listen for connection to the application (a connection + string is passed via the event) + - Type::Unaccept - stops listening for a connection to the app (determined by + a connection string passed via the event) + - Type::Appear - brings the app to the front (i.e. makes it "appear") + - Type::Version - display the app version + - Type::Help - opens a help topic (help topic passed as string) + - Type::OpenHELP_URL - opens a help URL (URL passed as a string) + - Type::ShowDialog - shows a dialog (dialog passed as a string) + - Type::Open - opens a document or group of documents (documents passed + as an array of strings) + - Type::Print - print a document or group of documents (documents passed + as an array of strings + - Type::PrivateDoShutdown - shutdown the app +*/ + +class VCL_DLLPUBLIC ApplicationEvent +{ +public: + enum class Type { + Accept, ///< Listen for connections + Appear, ///< Make application appear + Open, ///< Open a document + OpenHelpUrl, ///< Open a help URL + Print, ///< Print document + PrivateDoShutdown, ///< Shutdown application + QuickStart, ///< Start QuickStart + ShowDialog, ///< Show a dialog + Unaccept ///< Stop listening for connections + }; + + /** Explicit constructor for ApplicationEvent. + + @attention Type::Appear, Type::PrivateDoShutdown and + Type::QuickStart are the \em only events that don't need to include + a data string with the event. No other events should use this + constructor! + */ + explicit ApplicationEvent(Type type): aEvent(type) + { + assert(type == Type::Appear || type == Type::PrivateDoShutdown || type == Type::QuickStart); + } + + /** Constructor for ApplicationEvent, accepts a string for the data + associated with the event. + + @attention Type::Accept, Type::OpenHelpUrl, Type::ShowDialog + and Type::Unaccept are the \em only events that accept a single + string as event data. No other events should use this constructor! + */ + ApplicationEvent(Type type, OUString const & data): aEvent(type) + { + assert( + type == Type::Accept || type == Type::OpenHelpUrl + || type == Type::ShowDialog || type == Type::Unaccept); + aData.push_back(data); + } + + /** Constructor for ApplicationEvent, accepts an array of strings for + the data associated with the event. + + @attention Type::Open and Type::Print can apply to multiple documents, + and are the \em only events that accept an array of strings. No other + events should use this constructor. + */ + ApplicationEvent(Type type, std::vector<OUString> const & data): + aEvent(type), aData(data) + { + assert(type == Type::Open || type == Type::Print); + } + + /** Get the type of event. + + @returns The type of event. + */ + Type GetEvent() const + { + return aEvent; + } + + /** Gets the application event's data string. + + @attention The \em only events that need a single string Type::Accept, + Type::OpenHelpUrl, Type::ShowDialog and Type::Unaccept + + @returns The event's data string. + */ + OUString const & GetStringData() const + { + assert( + aEvent == Type::Accept + || aEvent == Type::OpenHelpUrl || aEvent == Type::ShowDialog + || aEvent == Type::Unaccept); + assert(aData.size() == 1); + return aData[0]; + } + + /** Gets the event's array of strings. + + @attention The \em only events that need an array of strings + are Type::Open and Type::Print. + */ + std::vector<OUString> const & GetStringsData() const + { + assert(aEvent == Type::Open || aEvent == Type::Print); + return aData; + } + +private: + Type aEvent; + std::vector<OUString> aData; +}; + +enum class DialogCancelMode { + Off, ///< do not automatically cancel dialogs + Silent, ///< silently cancel any dialogs + Fatal ///< cancel any dialogs by std::abort +}; + +/** + @brief Base class used mainly for the LibreOffice Desktop class. + + The Application class is a base class mainly used by the Desktop + class. It is really meant to be subclassed, and the Main() function + should be overridden. Many of the ImplSVData members should be + moved to this class. + + The reason Application exists is because the VCL used to be a + standalone framework, long since abandoned by anything other than + our application. + + @see Desktop, ImplSVData + */ +class VCL_DLLPUBLIC Application +{ +public: + /** @name Initialization + The following functions perform initialization and deinitialization + of the application. + */ + ///@{ + + /** Default constructor for Application class. + + Initializes the LibreOffice global instance data structure if needed, + and then sets itself to be the Application class. Also initializes any + platform specific data structures. + + @attention The initialization of the application itself is done in Init() + */ + Application(); + + /** Virtual destructor for Application class. + + Deinitializes the LibreOffice global instance data structure, then + deinitializes any platform specific data structures. + */ + virtual ~Application(); + + /** Initialize the application itself. + + @attention Note that the global data structures and platform specific + initialization is done in the constructor. + + @see InitFinished, DeInit + */ + virtual void Init(); + + /** Finish initialization of the application. + + @see Init, DeInit + */ + virtual void InitFinished(); + + /** Deinitialized the application itself. + + @attention Note that the global data structures and platform specific + deinitialization is done in the destructor. + + @see Init, InitFinished + */ + virtual void DeInit(); + + ///@} + + /** @brief Pure virtual entrypoint to the application. + + Main() is the pure virtual entrypoint to your application. You + inherit your class from Application and subclass this function to + implement an application. + + The Main() function does not pass in command line parameters, + you must use the functions GetCommandLineParamCount() and + GetCommandLineParam() to get these values as these are platform + independent ways of getting the command line (use GetAppFileName() + to get the invoked executable filename). + + Once in this function, you create windows, etc. then call on + Execute() to start the application's main event loop. + + An example code snippet follows (it won't compile, this just gives the + general flavour of the framework and is adapted from an old HelloWorld + example program that Star Division used to provide as part of their + library). + + \code{.cpp} + class TheApplication : public Application + { + public: + virtual void Main(); + }; + + class TheWindow : public WorkWindow + { + public: + TheWindow(vcl::Window *parent, WinBits windowStyle) : + WorkWindow(parent, windowStyle) {} + + virtual void Paint(const Rectangle &); + }; + + void TheWindow::Paint(const Rectangle&) + { + DrawText(Point(100,100), String("Hello World!")); + } + + void TheApplication::Main() + { + TheWindow aWindow(NULL, WB_APP | WB_STDWORK); + aWindow.Show(); + Execute(); + } + + TheApplication anApplication; + \endcode + + Some examples in the source tree can be found here: + + vcl/workben/svdem.cxx + + This is an example of how to use the Application and WorkWindow. Unfortunately, it + no longer compiles. + + vcl/fpicker/test/svdem.cxx + */ + virtual int Main(); + + /** Exit from the application + + @returns true if exited successfully, false if not able to fully exit + */ + virtual bool QueryExit(); + + virtual void Shutdown(); + + /** @name Change Notification Functions + + Functions that notify when changes occur in the application. + */ + ///@{ + + /** Notify all windows that the application has changed data. + + @param rDCEvt Reference to a DataChangedEvent object + + @see DataChanged + */ + static void NotifyAllWindows( DataChangedEvent& rDCEvt ); + + ///@} + + /** @name Command Line Processing + + Command line processing is done via the following functions. They + give the number of parameters, the parameters themselves and a way + to get the name of the invoking application. + */ + + ///@{ + + /** Gets the number of command line parameters passed to the application + + @return sal_uInt16 - the number of parameters + + @see GetCommandLineParam, GetAppFileName + */ + static sal_uInt16 GetCommandLineParamCount(); + + /** Gets a particular command line parameter + + @param nParam The index of the parameter to return. + + @return The command line parameter as an OUString + + @see GetCommandLineParamCount, GetAppFileName + */ + static OUString GetCommandLineParam( sal_uInt16 nParam ); + + /** Get the name of the file used to start the application + + @return The filename as an OUString + + @see GetCommandLineParamCount, GetCommandLineParam + */ + static OUString GetAppFileName(); + + ///@} + + /** @name Error Handling + + \em Very rudimentary error handling is done by these + functions. + + @{ + */ + + /** Handles an error. + + @param nCategory The error category, see include/vcl/exceptiontypes.hxx + + @see Abort + */ + virtual void Exception( ExceptionCategory nCategory ); + + /** Ends the program prematurely with an error message. + + If the \code --norestore \endcode command line argument is given (assuming + this process is run by developers who are interested in cores, + vs. end users who are not) then it does a coredump. + + @param rErrorText The error message to report. + + @see Exception + */ + static void Abort( const OUString& rErrorText ); + + ///@} + + /** @name Event Loop Functions + + Functions that handle the LibreOffice main event loop are here, + including a global lock called the Solar Mutex. + */ + ///@{ + + /** Run the main event processing loop until it is quit by Quit(). + + @see Quit, Reschedule, Yield, EndYield, GetSolarMutex, + IsMainThread, ReleaseSolarMutex, AcquireSolarMutex, + */ + static void Execute(); + + /** Quit the program + + @see Execute, Reschedule, Yield, EndYield, GetSolarMutex, + IsMainThread, ReleaseSolarMutex, AcquireSolarMutex, + */ + static void Quit(); + + /** Attempt to process current pending event(s) + + It doesn't sleep if no events are available for processing. + This doesn't process any events generated after invoking the function. + So in contrast to Scheduler::ProcessEventsToIdle, this cannot become + busy-locked by an event-generating event in the event queue. + + @param bHandleAllCurrentEvents If set to true, then try to process all + the current events. If set to false, then only process one event. + Defaults to false. + + @returns true if any event was processed. + + @see Yield, Scheduler::ProcessEventsToIdle + */ + static bool Reschedule( bool bHandleAllCurrentEvents = false ); + + /** Process the next event. + + It sleeps if no event is available for processing and just returns + if an event was processed. + + @see Execute, Quit, Reschedule, EndYield, GetSolarMutex, + IsMainThread, ReleaseSolarMutex, AcquireSolarMutex, + */ + static void Yield(); + + /** + + @see Execute, Quit, Reschedule, Yield, GetSolarMutex, + IsMainThread, ReleaseSolarMutex, AcquireSolarMutex, + */ + static void EndYield(); + + /** @brief Get the Solar Mutex for this thread. + + Get the Solar Mutex that prevents other threads from accessing VCL + concurrently. + + @returns SolarMutex reference + + @see Execute, Quit, Reschedule, Yield, EndYield, + IsMainThread, ReleaseSolarMutex, AcquireSolarMutex, + */ + static comphelper::SolarMutex& GetSolarMutex(); + + /** Queries whether we are in main thread. + + @returns true if we are in main thread, false if not + + @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex, + ReleaseSolarMutex, AcquireSolarMutex, + */ + static bool IsMainThread(); + + /** @brief Release Solar Mutex(es) for this thread + + Release the Solar Mutex(es) that prevents other threads from accessing + VCL concurrently. + + @returns The number of mutexes that were acquired by this thread. + + @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex, + IsMainThread, AcquireSolarMutex, + */ + static sal_uInt32 ReleaseSolarMutex(); + + /** @brief Acquire Solar Mutex(es) for this thread. + + Acquire the Solar Mutex(es) that prevents other threads from accessing + VCL concurrently. + + @see Execute, Quit, Reschedule, Yield, EndYield, GetSolarMutex, + IsMainThread, ReleaseSolarMutex, + */ + static void AcquireSolarMutex( sal_uInt32 nCount ); + + /** Queries whether the application is in "main", i.e. not yet in + the event loop + + @returns true if in main, false if not in main + + @see IsInExecute, IsInModalMode + */ + static bool IsInMain(); + + /** Queries whether the application is in the event loop + + @returns true if in the event loop, false if not + + @see IsInMain, IsInModalMode + */ + static bool IsInExecute(); + + /** Queries whether application has a modal dialog active. + + @returns true if a modal dialog is active, false if not + + @see IsInMain, IsInExecute + */ + static bool IsInModalMode(); + + /** Return how many events are being dispatched. + + @returns the number of events currently being dispatched + */ + static sal_uInt16 GetDispatchLevel(); + + /** Determine if there are any pending input events. + + @param nType input identifier, defined in include/vcl/inputtypes.hxx + The default is VCL_INPUT_ANY. + + @returns true if there are pending events, false if not. + + @see GetLastInputInterval + */ + static bool AnyInput( VclInputFlags nType = VCL_INPUT_ANY ); + + /** The interval from the last time that input was received. + + @returns system ticks - last input time + + @see AnyInput + */ + static sal_uInt64 GetLastInputInterval(); + + ///@} + + /* Determines if the UI is captured. + + The UI is considered captured if a system dialog is open (e.g. printer setup), + a floating window, menu or toolbox dropdown is open, or a window has been + captured by the mouse. + + @returns true if UI is captured, false if not + */ + static bool IsUICaptured(); + + /** @name Settings + + The following functions set system settings (e.g. tab color, etc.). There are functions + that set settings objects, and functions that set and get the actual system settings for + the application. + */ + ///@{ + + /** Sets user settings in settings object to override system settings + + The system settings that can be overridden are: + - window dragging options (on or off, including live scrolling!) + - style settings (e.g. checkbox color, border color, 3D colors, + button rollover colors, etc.) + - mouse settings + - menu options, including the mouse follows the menu and whether menu + icons are used + + @param rSettings Reference to the settings object to change. + + @see MergeSystemSettings, SetSettings, GetSettings + */ + virtual void OverrideSystemSettings( AllSettings& rSettings ); + + /** Set the settings object to the platform/desktop environment system + settings. + + @param rSettings Reference to the settings object to change. + + @see OverrideSystemSettings, SetSettings, GetSettings + */ + static void MergeSystemSettings( AllSettings& rSettings ); + + /** Sets the application's settings and notifies all windows of the + change. + + @param rSettings const reference to settings object used to + change the application's settings. + + @see OverrideSystemSettings, MergeSystemSettings, GetSettings + */ + static void SetSettings( const AllSettings& rSettings ); + + /** Gets the application's settings. If the application hasn't initialized + it's settings, then it does so (lazy initialization). + + @returns AllSettings instance that contains the current settings of the + application. + + @see OverrideSystemSettings, MergeSystemSettings, SetSettings + */ + static const AllSettings& GetSettings(); + + /** Get the application's locale data wrapper. + + @returns reference to a LocaleDataWrapper object + */ + static const LocaleDataWrapper& GetAppLocaleDataWrapper(); + + ///@} + + /** @name Event Listeners/Handlers + + A set of event listeners and callers. Note that in this code there is + platform specific functions - namely for zoom and scroll events. + */ + ///@{ + + + /** Add a VCL event listener to the application. If no event listener exists, + then initialize the application's event listener with a new one, then add + the event listener. + + @param rEventListener Const reference to the event listener to add. + + @see RemoveEventListener, AddKeyListener, RemoveKeyListener + */ + static void AddEventListener( const Link<VclSimpleEvent&,void>& rEventListener ); + + /** Remove a VCL event listener from the application. + + @param rEventListener Const reference to the event listener to be removed + + @see AddEventListener, AddKeyListener, RemoveKeyListener + */ + static void RemoveEventListener( const Link<VclSimpleEvent&,void>& rEventListener ); + + /** Add a keypress listener to the application. If keypress listener exists, + then initialize the application's keypress event listener with a new one, then + add the keypress listener. + + @param rKeyListener Const reference to the keypress event listener to add + + @see AddEventListener, RemoveEventListener, RemoveKeyListener + */ + static void AddKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener ); + + /** Remove a keypress listener from the application. + + @param rKeyListener Const reference to the keypress event listener to be removed + + @see AddEventListener, RemoveEventListener, AddKeyListener + */ + static void RemoveKeyListener( const Link<VclWindowEvent&,bool>& rKeyListener ); + + /** Send event to all VCL application event listeners + + @param pWin Pointer to window to send event + @param pData Pointer to data to send with event + + @see ImplCallEventListeners(VclSimpleEvent* pEvent) + */ + static void ImplCallEventListenersApplicationDataChanged( void* pData ); + + /** Send event to all VCL application event listeners + + @param rEvent Reference to VclSimpleEvent + + @see ImplCallEventListeners(sal_uLong nEvent, Windows* pWin, void* pData); + */ + static void ImplCallEventListeners( VclSimpleEvent& rEvent ); + + /** Handle keypress event + + @param nEvent Event ID for keypress + @param pWin Pointer to window that receives the event + @param pKeyEvent Received key event + + @see PostKeyEvent + */ + static bool HandleKey( VclEventId nEvent, vcl::Window *pWin, KeyEvent* pKeyEvent ); + + /** Send keypress event + + @param nEvent Event ID for keypress + @param pWin Pointer to window to which the event is sent + @param pKeyEvent Key event to send + + @see HandleKey + */ + static ImplSVEvent * PostKeyEvent( VclEventId nEvent, vcl::Window *pWin, KeyEvent const * pKeyEvent ); + + /** Send mouse event + + @param nEvent Event ID for mouse event + @param pWin Pointer to window to which the event is sent + @param pMouseEvent Mouse event to send + */ + static ImplSVEvent * PostMouseEvent( VclEventId nEvent, vcl::Window *pWin, MouseEvent const * pMouseEvent ); + + static ImplSVEvent* PostGestureEvent(VclEventId nEvent, vcl::Window* pWin, GestureEvent const * pGestureEvent); + + /** Remove mouse and keypress events from a window... any also zoom and scroll events + if the platform supports it. + + @param pWin Window to remove events from + + @see HandleKey, PostKeyEvent, PostMouseEvent + */ + static void RemoveMouseAndKeyEvents( vcl::Window *pWin ); + + /** Post a user event to the default window. + + User events allow for the deferral of work to later in the main-loop - at idle. + + Execution of the deferred work is thread-safe which means all the tasks are executed + serially, so no thread-safety locks between tasks are necessary. + + @param rLink Link to event callback function + @param pCaller Pointer to data sent to the event by the caller. Optional. + @param bReferenceLink If true - hold a VclPtr<> reference on the Link's instance. + Taking the reference is guarded by a SolarMutexGuard. + + @return the event ID used to post the event. + */ + static ImplSVEvent * PostUserEvent( const Link<void*,void>& rLink, void* pCaller = nullptr, + bool bReferenceLink = false ); + + /** Remove user event based on event ID + + @param nUserEvent User event to remove + */ + static void RemoveUserEvent( ImplSVEvent * nUserEvent ); + + /*** Get the DisplayConnection. + + It is a reference to XDisplayConnection, which allows toolkits to send display + events to the application. + + @returns UNO reference to an object that implements the css:awt:XDisplayConnection + interface. + */ + static css::uno::Reference< css::awt::XDisplayConnection > GetDisplayConnection(); + + /** @deprecated AppEvent is used only in the Desktop class now. However, it is + intended to notify the application that an event has occurred. It was in oldsv.cxx, + but is still needed by a number of functions. + + @param rAppEvent const reference to ApplicationEvent event + */ + virtual void AppEvent( const ApplicationEvent& rAppEvent ); + + ///@} + + /** @name Application Window Functions + + Functions that deal with the application's windows + */ + ///@{ + + /** Get the currently focused window. + + @returns Pointer to focused window. + + @see GetDefaultDevice + */ + static vcl::Window* GetFocusWindow(); + + /** Get the default "device" (in this case the default window). + + @returns Pointer to an OutputDevice. However, it is a Window object - + Window class subclasses OutputDevice. + + @see GetFocusWindow + */ + static OutputDevice* GetDefaultDevice(); + + /** Get the first top-level window of the application. + + @returns Pointer to top-level window (a Window object) + + @see GetNextTopLevelWindow, GetTopWindowCount, GetTopWindow, + GetActiveTopWindow + */ + static vcl::Window* GetFirstTopLevelWindow(); + + /** Get the next top level window. + + @param pWindow Pointer to Window object you wish to get the next + window from. + + @returns Pointer to next top window. + */ + static vcl::Window* GetNextTopLevelWindow( vcl::Window const * pWindow ); + + /** Return the number of top-level windows being used by the application + + @returns the number of top-level windows + + @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindow, + GetActiveTopWindow + + */ + static long GetTopWindowCount(); + + /** Get the nth top window. + + @remark Top windows are actually implemented in a one-way linked list. + This iterates through top level windows n times. + + @param nIndex The index of the top-level window + + @returns The nth top-level window of the application + + @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount, + GetActiveTopWindow + */ + static vcl::Window* GetTopWindow( long nIndex ); + + /** Get the "active" top window. + + An "active" top window is one that has a child window that has the + application's focus. + + @returns the active top window + + @see GetFirstTopLevelWindow, GetNextTopLevelWindow, GetTopWindowCount, + GetTopWindow + */ + static vcl::Window* GetActiveTopWindow(); + + ///@} + + /** Set the application's name. + + @param rUniqueName What to set the application name to + + @see GetAppName + */ + static void SetAppName( const OUString& rUniqueName ); + + + /** @name Application Name, Branding + */ + ///@{ + + /** Get the application's name. + + @returns The application name. + */ + static OUString GetAppName(); + + /** Get useful OS, Hardware and configuration information, + * cf. Help->About, and User-Agent + * bSelection = 0 to return all info, 1 for environment only, + * and 2 for VCL/render related infos + */ + static OUString GetHWOSConfInfo(const int bSelection = 0, bool bLocalize = true); + + /** Load a localized branding PNG file as a bitmap. + + @param pName Name of the bitmap to load. + @param rBitmap Reference to BitmapEx object to load PNG into + + @returns true if the PNG could be loaded, otherwise returns false. + */ + static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap); + + ///@} + + /** @name Display and Screen + */ + ///@{ + + /** Set the default name of the application for message dialogs and printing. + + @param rDisplayName const reference to string to set the Display name to. + + @see GetDisplayName + */ + static void SetDisplayName( const OUString& rDisplayName ); + + /** Get the default name of the application for message dialogs and printing. + + @returns The display name of the application. + */ + static OUString GetDisplayName(); + + /** Get the toolkit's name. e.g. gtk3 + + @returns The toolkit name. + */ + static OUString GetToolkitName(); + + /** Get the number of screens available for the display. + + @returns The number of screens available. + + @see GetScreenPosSizePixel + */ + static unsigned int GetScreenCount(); + + /** Get a screen's rectangular area. + + @param nScreen The number of the screen requested. + + @returns The area of the screen in a Rectangle object. + + @see GetScreenCount + */ + static tools::Rectangle GetScreenPosSizePixel( unsigned int nScreen ); + + /** Determines if the screens that make up a display are separate or + form one large display area. + + @returns true when screens form up one large display area windows can be + moved between single screens (e.g. Xserver with Xinerama, Windows) + and false when different screens are separate and windows cannot be moved + between them (e.g. Xserver with multiple screens) + + @see GetBestScreen, GetDisplayBuiltInScreen + */ + static bool IsUnifiedDisplay(); + + /** Get the "best" screen. + + @returns If IsUnifiedDisplay() == true the return value will be + nearest screen of the target rectangle. + + In case of IsUnifiedDisplay() == false the return value + will always be GetDisplayDefaultScreen(). + + @see IsUnifiedDisplay, GetDisplayBuiltInScreen + */ + SAL_DLLPRIVATE static unsigned int GetBestScreen( const tools::Rectangle& ); + + /** Get the built-in screen. + + @return + This returns the LCD screen number for a laptop, or the primary + external VGA display for a desktop machine - it is where a presenter + console should be rendered if there are other (non-built-in) screens + present. + + @see IsUnifiedDisplay, GetBestScreen + */ + static unsigned int GetDisplayBuiltInScreen(); + + /** Get the display's external screen. + + Practically, this means - Get the screen we should run a presentation on. + + @returns 0 or 1 currently, will fallback to the first available screen if + there are more than one external screens. May be changed in the future. + */ + static unsigned int GetDisplayExternalScreen(); + + ///@} + + /** @name Accelerators and Mnemonics + + Accelerators allow a user to hold down Ctrl+key (or CMD+key on macOS) + combination to gain quick access to functionality. + + Mnemonics are underline letters in things like menus and dialog boxes + that allow a user to type in the letter to activate the menu or option. + */ + ///@{ + + /** Insert accelerator + + @param pAccel Pointer to an Accelerator object to insert + + @returns true if successful, false if otherwise + + @see RemoveAccel + */ + static bool InsertAccel( Accelerator* pAccel ); + + /** Remove accelerator + + @param pAccel Pointer to Accelerator object to remove + + @see InsertAccel + */ + static void RemoveAccel( Accelerator const * pAccel ); + + /** Get the number of reserved key codes used by the application. + + @returns number of reserved key codes + + @see GetReservedKeyCode + */ + static size_t GetReservedKeyCodeCount(); + + /** Get the reserved key code. + + @param i The keycode number to retrieve + + @returns Const pointer to a KeyCode object + + @see GetReservedKeyCodeCount + */ + static const vcl::KeyCode* GetReservedKeyCode( size_t i ); + + ///@} + + /** @name Application Help + + Deals with the help system, and "auto-help", where a user hovers a mouse above + a UI element and a tooltip with an explanation pops up. + */ + ///@{ + + /** Sets up help + + @param pHelp Pointer to a Help object (optional, can by NULL) + + @see GetHelp + */ + static void SetHelp( Help* pHelp = nullptr ); + + /** Gets the application's help + + @returns Pointer to application's help object. Note that the application may + not have a help object, so it might return NULL. + + @see SetHelp + */ + static Help* GetHelp(); + + ///@} + + /** @name Dialogs + + @remark "Dialog cancel mode" tells a headless install whether to + cancel dialogs when they appear. See the DialogCancelMode + enumerator. + */ + ///@{ + + /** Get the default parent window for dialog boxes. + + @remark GetDefDialogParent does all sorts of things find a useful parent + window for dialogs. It first uses the topmost parent of the active + window to avoid using floating windows or other dialog boxes. If + there are no active windows, then it will take a random stab and + choose the first visible top window. Otherwise, it defaults to + the desktop. + + @returns Pointer to the default window. + */ + static vcl::Window* GetDefDialogParent(); + + + /** Gets the dialog cancel mode for headless environments. + + @return DialogCancelMode value + + @see SetDialogCancelMode, IsDialogCancelEnabled + */ + static DialogCancelMode GetDialogCancelMode(); + + /** Sets the dialog cancel mode for headless environments. + + This should be private, but XFrameImpl needs to access it and current + baseline gcc doesn't support forward definition of anonymous classes. + You probably should use EnableHeadlessMode instead. + + @param mode DialogCancel mode value + + @see GetDialogCancelMode, IsDialogCancelEnabled, EnableHeadlessMode + */ + static void SetDialogCancelMode( DialogCancelMode mode ); + + /** Determines if dialog cancel mode is enabled. + + @returns True if dialog cancel mode is enabled, false if disabled. + + @see GetDialogCancelMode, SetDialogCancelMode + */ + static bool IsDialogCancelEnabled(); + + + /** Make a dialog box a system window or not. + + @param nMode Can be either: SystemWindowFlags::NOAUTOMODE (0x0001) or + SystemWindowFlags::DIALOG (0x0002) + + @see GetSystemWindowMode + */ + static void SetSystemWindowMode( SystemWindowFlags nMode ); + + /** Get the system window mode of dialogs. + + @returns SystemWindowFlags::NOAUTOMODE (0x0001) or SystemWindowFlags::DIALOG (0x0002) + + @see SetSystemWindowMode + */ + static SystemWindowFlags GetSystemWindowMode(); + + ///@} + + /** @name VCL Toolkit and UNO Wrapper + + The VCL Toolkit implements the UNO XToolkit interface, which specifies a + factory interface for the window toolkit. It is similar to the abstract window + toolkit (AWT) in Java. + + */ + ///@{ + + /** Gets the VCL toolkit. + + @attention The global service manager has to be created before getting the toolkit! + + @returns UNO reference to VCL toolkit + */ + static css::uno::Reference< css::awt::XToolkit > GetVCLToolkit(); + + ///@} + + + /*** @name Graphic Filters + */ + ///@{ + + /** Setup a new graphics filter + + @param rLink Const reference to a Link object, which the filter calls upon. + + @see GetFilterHdl + */ + static void SetFilterHdl( const Link<ConvertData&,bool>& rLink ); + + ///@} + + /** @name Headless Mode + */ + + /** Enables headless mode. + + @param dialogsAreFatal Set to true if a dialog ends the session, false if not. + */ + static void EnableHeadlessMode( bool dialogsAreFatal ); + + /** Determines if headless mode is enabled + + @return True if headless mode is enabled, false if not. + */ + static bool IsHeadlessModeEnabled(); + + /** Enable Console Only mode + + Convenience function to enable headless and bitmap rendering. + */ + static void EnableConsoleOnly(); + + /** Enable software-only bitmap rendering + */ + static void EnableBitmapRendering(); + + /** Determines if bitmap rendering is enabled + + @return True if bitmap rendering is enabled. + */ + static bool IsBitmapRendering(); + + ///@} + + /** @name Event Testing Mode + */ + + /** Enables event testing mode. + + */ + static void EnableEventTestingMode(); + + /** Determines if event testing mode is enabled + + @return True if event testing mode is enabled, false if not. + */ + static bool IsEventTestingModeEnabled(); + + /** Set safe mode to enabled */ + static void EnableSafeMode(); + + /** Determines if safe mode is enabled */ + static bool IsSafeModeEnabled(); + + ///@} + + /** Get the desktop environment the process is currently running in + + @returns String representing the desktop environment + */ + static const OUString& GetDesktopEnvironment(); + + /*** @name Platform Functionality + */ + ///@{ + + /** Add a file to the system shells recent document list if there is any. + This function may have no effect under Unix because there is no standard + API among the different desktop managers. + + @param rFileUrl The file url of the document. + + @param rMimeType The mime content type of the document specified by aFileUrl. + If an empty string will be provided "application/octet-stream" + will be used. + + @param rDocumentService The app (or "document service") you will be adding the file to + e.g. com.sun.star.text.TextDocument + */ + static void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService); + + /*** Show a native error messagebox + + @param sTitle Title of error messagebox + + @param sMessage Message displayed in messagebox + */ + static void ShowNativeErrorBox(const OUString& sTitle , + const OUString& sMessage); + + /** Update main thread identifier */ + static void UpdateMainThread(); + + /** Do we have a native / system file selector available? + + @returns True if native file selector is available, false otherwise. + */ + static bool hasNativeFileSelection(); + + /** Create a platform specific file picker, if one is available, otherwise return an + empty reference. + + @param rServiceManager Const reference to a UNO component context (service manager). + + @returns File picker if available, otherwise an empty reference. + */ + static css::uno::Reference< css::ui::dialogs::XFilePicker2 > + createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager ); + + /** Create a platform specific folder picker, if one is available, otherwise return an + empty reference + + @param rServiceManager Const reference to a UNO component context (service manager). + + @returns Folder picker if available, otherwise an empty reference. + */ + static css::uno::Reference< css::ui::dialogs::XFolderPicker2 > + createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& rServiceManager ); + + /** Cancel all open dialogs + */ + static void EndAllDialogs(); + + /** Cancel all open popups + */ + static void EndAllPopups(); + + ///@} + + // For vclbootstrapprotector: + static void setDeInitHook(Link<LinkParamNone*,void> const & hook); + + static weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString &rUIFile, bool bMobile = false); + static weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile); //for the duration of vcl parent windows + + static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, + VclButtonsType eButtonType, const OUString& rPrimaryMessage); + + static weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow); +private: + DECL_STATIC_LINK( Application, PostEventHandler, void*, void ); +}; + +class SolarMutexGuard + : public osl::Guard<comphelper::SolarMutex> +{ +public: + SolarMutexGuard() + : osl::Guard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {} +}; + +class SolarMutexClearableGuard + : public osl::ClearableGuard<comphelper::SolarMutex> +{ +public: + SolarMutexClearableGuard() + : osl::ClearableGuard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {} +}; + +class SolarMutexResettableGuard + : public osl::ResettableGuard<comphelper::SolarMutex> +{ +public: + SolarMutexResettableGuard() + : osl::ResettableGuard<comphelper::SolarMutex>( Application::GetSolarMutex() ) {} +}; + +namespace vcl +{ + +/** guard class that uses tryToAcquire() and has isAcquired() to check + */ +class SolarMutexTryAndBuyGuard +{ +private: + bool m_isAcquired; +#ifdef DBG_UTIL + bool m_isChecked; +#endif + comphelper::SolarMutex& m_rSolarMutex; + + SolarMutexTryAndBuyGuard(const SolarMutexTryAndBuyGuard&) = delete; + SolarMutexTryAndBuyGuard& operator=(const SolarMutexTryAndBuyGuard&) = delete; + +public: + + SolarMutexTryAndBuyGuard() + : m_isAcquired(false) +#ifdef DBG_UTIL + , m_isChecked(false) +#endif + , m_rSolarMutex(Application::GetSolarMutex()) + + { + m_isAcquired = m_rSolarMutex.tryToAcquire(); + } + + ~SolarMutexTryAndBuyGuard() + { +#ifdef DBG_UTIL + assert(m_isChecked); +#endif + if (m_isAcquired) + m_rSolarMutex.release(); + } + + bool isAcquired() + { +#ifdef DBG_UTIL + m_isChecked = true; +#endif + return m_isAcquired; + } +}; + +} // namespace vcl + +/** + A helper class that calls Application::ReleaseSolarMutex() in its constructor + and restores the mutex in its destructor. +*/ +class SolarMutexReleaser +{ + const sal_uInt32 mnReleased; +public: + SolarMutexReleaser(): mnReleased(Application::ReleaseSolarMutex()) {} + ~SolarMutexReleaser() { Application::AcquireSolarMutex( mnReleased ); } +}; + +VCL_DLLPUBLIC Application* GetpApp(); + +// returns true if vcl is already initialized +VCL_DLLPUBLIC bool IsVCLInit(); +// returns true if vcl successfully initializes or was already initialized +VCL_DLLPUBLIC bool InitVCL(); +VCL_DLLPUBLIC void DeInitVCL(); + +VCL_DLLPUBLIC bool InitAccessBridge(); + +// only allowed to call, if no thread is running. You must call JoinMainLoopThread to free all memory. +VCL_DLLPUBLIC void CreateMainLoopThread( oslWorkerFunction pWorker, void * pThreadData ); +VCL_DLLPUBLIC void JoinMainLoopThread(); + +/// The following are to manage per-view (frame) help data. +struct ImplSVHelpData; +VCL_DLLPUBLIC ImplSVHelpData* CreateSVHelpData(); +VCL_DLLPUBLIC void DestroySVHelpData(ImplSVHelpData*); +VCL_DLLPUBLIC void SetSVHelpData(ImplSVHelpData*); + +/// The following are to manage per-view (frame) window data. +struct ImplSVWinData; +VCL_DLLPUBLIC ImplSVWinData* CreateSVWinData(); +VCL_DLLPUBLIC void DestroySVWinData(ImplSVWinData*); +VCL_DLLPUBLIC void SetSVWinData(ImplSVWinData*); + +inline void Application::EndYield() +{ + PostUserEvent( Link<void*,void>() ); +} + +#endif // _APP_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 000000000..abe2446ad --- /dev/null +++ b/include/vcl/svlbitm.hxx @@ -0,0 +1,288 @@ +/* -*- 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 <memory> +#include <vcl/dllapi.h> +#include <tools/link.hxx> +#include <vcl/image.hxx> +#include <vcl/treelistbox.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SvTreeListEntry; +class SvLBoxButton; + + +enum class SvBmp +{ + UNCHECKED = 0, + CHECKED = 1, + TRISTATE = 2, + HIUNCHECKED = 3, + HICHECKED = 4, + HITRISTATE = 5 +}; + +enum class SvItemStateFlags +{ + NONE = 0x00, + UNCHECKED = 0x01, + CHECKED = 0x02, + TRISTATE = 0x04, + HILIGHTED = 0x08 +}; +namespace o3tl +{ + template<> struct typed_flags<SvItemStateFlags> : is_typed_flags<SvItemStateFlags, 0x0f> {}; +} + +struct SvLBoxButtonData_Impl; + +class VCL_DLLPUBLIC SvLBoxButtonData +{ +private: + Link<SvLBoxButtonData*,void> aLink; + long nWidth; + long nHeight; + std::unique_ptr<SvLBoxButtonData_Impl> pImpl; + bool bDataOk; + std::vector<Image> 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<SvLBoxButtonData*,void>& rLink) { aLink=rLink; } + bool IsRadio() const; + // as buttons are not derived from LinkHdl + void CallLink(); + + void StoreButtonState(SvTreeListEntry* pActEntry, SvLBoxButton* pActBox); + static SvButtonState ConvertToButtonState( SvItemStateFlags nItemFlags ); + + SvTreeListEntry* GetActEntry() const; + SvLBoxButton* GetActBox() const; + + void SetImage(SvBmp nIndex, const Image& aImage) { aBmps[static_cast<int>(nIndex)] = aImage; } + Image& GetImage(SvBmp nIndex) { return aBmps[static_cast<int>(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 +{ +private: + bool mbEmphasized; + bool mbCustom; + double mfAlign; +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; + + virtual int CalcWidth(const SvTreeListBox* pView) const override; + + void Align(double fAlign) { mfAlign = fAlign; } + + void Emphasize(bool bEmphasize) { mbEmphasized = bEmphasize; } + bool IsEmphasized() const { return mbEmphasized; } + + void SetCustomRender() { mbCustom = true; } + + 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<SvLBoxItem> Clone(SvLBoxItem const * pSource) const override; +}; + +class SvLBoxButton : public SvLBoxItem +{ + bool isVis; + SvLBoxButtonData* pData; + SvItemStateFlags nItemFlags; + + static void ImplAdjustBoxSize( Size& io_rCtrlSize, ControlType i_eType, vcl::RenderContext const & pRenderContext); +public: + // An SvLBoxButton can be of two different kinds: an + // enabled checkbox (the normal kind), or a static image + // (see SV_BMP_STATICIMAGE; nFlags are effectively ignored + // for that kind). + SvLBoxButton( 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<SvLBoxItem> 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); +}; + +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<SvLBoxContextBmp_Impl> 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<SvLBoxItem> 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<SvLBoxContextBmp*>(this)->implGetImageStore(true); + return rImage; +} + +inline const Image& SvLBoxContextBmp::GetBitmap2() const +{ + Image& rImage = const_cast<SvLBoxContextBmp*>(this)->implGetImageStore(false); + return rImage; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/svmain.hxx b/include/vcl/svmain.hxx new file mode 100644 index 000000000..ca6010784 --- /dev/null +++ b/include/vcl/svmain.hxx @@ -0,0 +1,33 @@ +/* -*- 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_SVMAIN_HXX +#define INCLUDED_VCL_SVMAIN_HXX + +#include <sal/config.h> +#include <vcl/dllapi.h> + +// #i47888# allow for alternative initialization as required for e.g. MacOSX +VCL_DLLPUBLIC int ImplSVMain(); + +VCL_DLLPUBLIC int SVMain(); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/svtaccessiblefactory.hxx b/include/vcl/svtaccessiblefactory.hxx new file mode 100644 index 000000000..14bcc6532 --- /dev/null +++ b/include/vcl/svtaccessiblefactory.hxx @@ -0,0 +1,59 @@ +/* -*- 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_INCLUDE_VCL_SVTACCESSIBLEFACTORY_HXX +#define INCLUDED_INCLUDE_VCL_SVTACCESSIBLEFACTORY_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> + +namespace vcl { class IAccessibleFactory; } + +namespace vcl +{ + /** a client for the accessibility implementations which have been outsourced + from the main vcl/svtools libraries + + All instances of this class share a reference to a common IAccessibleFactory + instance, which is used for creating all kind of Accessibility related + components. + + When the AccessibleFactoryAccess goes away, also this factory goes away, and the respective + library is unloaded. + + This class is not thread-safe. + */ + class UNLESS_MERGELIBS(VCL_DLLPUBLIC) AccessibleFactoryAccess + { + private: + bool m_bInitialized; + + public: + AccessibleFactoryAccess(); + + IAccessibleFactory& getFactory(); + + private: + void ensureInitialized(); + }; +} // namespace svt + +#endif // INCLUDED_INCLUDE_VCL_SVTACCESSIBLEFACTORY_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/syschild.hxx b/include/vcl/syschild.hxx new file mode 100644 index 000000000..11d85b029 --- /dev/null +++ b/include/vcl/syschild.hxx @@ -0,0 +1,67 @@ +/* -*- 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_SYSCHILD_HXX +#define INCLUDED_VCL_SYSCHILD_HXX + +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +struct SystemEnvData; +struct SystemWindowData; + +class VCL_DLLPUBLIC SystemChildWindow : public vcl::Window +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInitSysChild( vcl::Window* pParent, WinBits nStyle, SystemWindowData *pData, bool bShow = false ); + + // Copy assignment is forbidden and not implemented. + SystemChildWindow (const SystemChildWindow &) = delete; + SystemChildWindow & operator= (const SystemChildWindow &) = delete; + +public: + explicit SystemChildWindow( vcl::Window* pParent, WinBits nStyle ); + // create a SystemChildWindow using the given SystemWindowData + explicit SystemChildWindow( vcl::Window* pParent, WinBits nStyle, SystemWindowData *pData, bool bShow = true ); + virtual ~SystemChildWindow() override; + virtual Size GetOptimalSize() const override; + virtual void dispose() override; + + virtual const SystemEnvData* GetSystemData() const override; + + // per default systemchildwindows erase their background for better plugin support + // however, this might not always be required + void EnableEraseBackground( bool bEnable ); + void SetForwardKey( bool bEnable ); + //To avoid annoying flashing under X entering and leaving slides with opengl effects set the leaving + //bitmap as the background pixmap of the opengl child window and the entering bitmap as the background + //pixmap of the non-opengl parent window. If any expose events occur around the start and end of + //the transition then those windows are default filled by X with the desired start/end image so there's + //no visible flash + void SetLeaveEnterBackgrounds(const css::uno::Sequence<css::uno::Any>& rLeaveArgs, const css::uno::Sequence<css::uno::Any>& rEnterArgs); + // return the platform specific handle/id of this window; + sal_IntPtr GetParentWindowHandle() const; + + void* CreateGStreamerSink(); +}; + +#endif // INCLUDED_VCL_SYSCHILD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/sysdata.hxx b/include/vcl/sysdata.hxx new file mode 100644 index 000000000..3152fa3be --- /dev/null +++ b/include/vcl/sysdata.hxx @@ -0,0 +1,233 @@ +/* -*- 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_SYSDATA_HXX +#define INCLUDED_VCL_SYSDATA_HXX + +#include <sal/types.h> + +#include <vector> + +#include <config_cairo_canvas.h> + +#ifdef MACOSX +// predeclare the native classes to avoid header/include problems +typedef struct CGContext *CGContextRef; +typedef struct CGLayer *CGLayerRef; +typedef const struct __CTFont * CTFontRef; +#ifdef __OBJC__ +@class NSView; +#else +class NSView; +#endif +#endif + +#ifdef IOS +typedef const struct __CTFont * CTFontRef; +typedef struct CGContext *CGContextRef; +#endif + +#if defined(_WIN32) +#include <prewin.h> +#include <windef.h> +#include <postwin.h> +#endif + +struct SystemEnvData +{ +#if defined(_WIN32) + HWND hWnd; // the window hwnd +#elif defined( MACOSX ) + NSView* mpNSView; // the cocoa (NSView *) implementing this object + bool mbOpenGL; // use an OpenGL providing NSView +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#elif defined( UNX ) + enum class Toolkit { Gtk3, Qt5, Gen }; + enum class Platform { Wayland, Xcb }; + + void* pDisplay; // the relevant display connection + unsigned long aWindow; // the window of the object + void* pSalFrame; // contains a salframe, if object has one + void* pWidget; // the corresponding widget + void* pVisual; // the visual in use + int nScreen; // the current screen of the window + // note: this is a "long" in Xlib *but* in the protocol it's only 32-bit + // however, the GTK3 vclplug wants to store pointers in here! + sal_IntPtr aShellWindow; // the window of the frame's shell + Toolkit toolkit; // the toolkit in use + Platform platform; // the windowing system in use +#endif + + SystemEnvData() +#if defined(_WIN32) + : hWnd(nullptr) +#elif defined( MACOSX ) + : mpNSView(nullptr) + , mbOpenGL(false) +#elif defined( ANDROID ) +#elif defined( IOS ) +#elif defined( UNX ) + : pDisplay(nullptr) + , aWindow(0) + , pSalFrame(nullptr) + , pWidget(nullptr) + , pVisual(nullptr) + , nScreen(0) + , aShellWindow(0) + , toolkit(Toolkit()) + , platform(Platform()) +#endif + { + } +}; + +struct SystemParentData +{ + sal_uInt32 nSize; // size in bytes of this structure +#if defined(_WIN32) + HWND hWnd; // the window hwnd +#elif defined( MACOSX ) + NSView* pView; // the cocoa (NSView *) implementing this object +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#elif defined( UNX ) + long aWindow; // the window of the object + bool bXEmbedSupport:1; // decides whether the object in question + // should support the XEmbed protocol +#endif +}; + +struct SystemMenuData +{ +#if defined(_WIN32) + HMENU hMenu; // the menu handle of the menu bar +#else + // Nothing +#endif +}; + +struct SystemGraphicsData +{ + sal_uInt32 nSize; // size in bytes of this structure +#if defined(_WIN32) + HDC hDC; // handle to a device context + HWND hWnd; // optional handle to a window +#elif defined( MACOSX ) + CGContextRef rCGContext; // CoreGraphics graphic context +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + CGContextRef rCGContext; // CoreGraphics graphic context +#elif defined( UNX ) + void* pDisplay; // the relevant display connection + long hDrawable; // a drawable + void* pVisual; // the visual in use + int nScreen; // the current screen of the drawable + void* pXRenderFormat; // render format for drawable + void* pSurface; // the cairo surface when using svp-based backends +#endif + SystemGraphicsData() + : nSize( sizeof( SystemGraphicsData ) ) +#if defined(_WIN32) + , hDC( nullptr ) + , hWnd( nullptr ) +#elif defined( MACOSX ) + , rCGContext( nullptr ) +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + , rCGContext( NULL ) +#elif defined( UNX ) + , pDisplay( nullptr ) + , hDrawable( 0 ) + , pVisual( nullptr ) + , nScreen( 0 ) + , pXRenderFormat( nullptr ) + , pSurface( nullptr ) +#endif + { } +}; + +struct SystemWindowData +{ +#if defined(_WIN32) // meaningless on Windows +#elif defined( MACOSX ) + bool bOpenGL; // create an OpenGL providing NSView + bool bLegacy; // create a 2.1 legacy context, only valid if bOpenGL == true +#elif defined( ANDROID ) + // Nothing +#elif defined( IOS ) + // Nothing +#elif defined( UNX ) + void* pVisual; // the visual to be used + bool bClipUsingNativeWidget; // default is false, true will attempt to clip the childwindow with a native widget +#endif +}; + +struct SystemGlyphData +{ + sal_uInt32 index; + double x; + double y; + int fallbacklevel; +}; + +#if ENABLE_CAIRO_CANVAS + +struct SystemFontData +{ +#if defined( UNX ) + void* nFontId; // native font id + int nFontFlags; // native font flags +#endif + bool bFakeBold; // Does this font need faking the bold style + bool bFakeItalic; // Does this font need faking the italic style + bool bAntialias; // Should this font be antialiased + bool bVerticalCharacterType; // Is the font using vertical character type + + SystemFontData() + : +#if defined( UNX ) + nFontId( nullptr ), + nFontFlags( 0 ), +#endif + bFakeBold( false ), + bFakeItalic( false ), + bAntialias( true ), + bVerticalCharacterType( false ) + { + } +}; + +#endif // ENABLE_CAIRO_CANVAS + +struct SystemTextLayoutData +{ + std::vector<SystemGlyphData> rGlyphData; // glyph data + int orientation; // Text orientation +}; + +#endif // INCLUDED_VCL_SYSDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/syswin.hxx b/include/vcl/syswin.hxx new file mode 100644 index 000000000..f1cb60015 --- /dev/null +++ b/include/vcl/syswin.hxx @@ -0,0 +1,230 @@ +/* -*- 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_SYSWIN_HXX +#define INCLUDED_VCL_SYSWIN_HXX + +#include <vcl/dllapi.h> +#include <vcl/builder.hxx> +#include <vcl/idle.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/window.hxx> +#include <vcl/windowstate.hxx> +#include <o3tl/typed_flags_set.hxx> +#include <memory> +#include <vcl/NotebookBarAddonsMerger.hxx> + +class MenuBar; +class NotebookBar; +class TaskPaneList; + +#define ICON_LO_DEFAULT 1 +#define ICON_TEXT_DOCUMENT 2 +#define ICON_SPREADSHEET_DOCUMENT 4 +#define ICON_DRAWING_DOCUMENT 6 +#define ICON_PRESENTATION_DOCUMENT 8 +#define ICON_TEMPLATE 11 +#define ICON_DATABASE_DOCUMENT 12 +#define ICON_MATH_DOCUMENT 13 +#define ICON_MACROLIBRARY 1 + +enum class MenuBarMode +{ + Normal, Hide +}; + +enum class TitleButton +{ + Docking = 1, + Hide = 2, + Menu = 4, +}; + +class VCL_DLLPUBLIC SystemWindow + : public vcl::Window + , public VclBuilderContainer +{ + friend class WorkWindow; + class ImplData; + +private: + VclPtr<MenuBar> mpMenuBar; + Size maOrgSize; + Size maRollUpOutSize; + Size maMinOutSize; + bool mbRollUp; + bool mbDockBtn; + bool mbHideBtn; + bool mbSysChild; + bool mbIsCalculatingInitialLayoutSize; + bool mbPaintComplete; + MenuBarMode mnMenuBarMode; + sal_uInt16 mnIcon; + std::unique_ptr<ImplData> mpImplData; + Idle maLayoutIdle; + OUString maNotebookBarUIFile; +protected: + bool mbIsDeferredInit; + VclPtr<vcl::Window> mpDialogParent; +public: + using Window::ImplIsInTaskPaneList; + SAL_DLLPRIVATE bool ImplIsInTaskPaneList( vcl::Window* pWin ); + SAL_DLLPRIVATE bool isDeferredInit() const { return mbIsDeferredInit; } + +private: + SAL_DLLPRIVATE void ImplMoveToScreen( long& io_rX, long& io_rY, long i_nWidth, long i_nHeight, vcl::Window const * i_pConfigureWin ); + SAL_DLLPRIVATE void setPosSizeOnContainee(Size aSize, Window &rBox); + DECL_DLLPRIVATE_LINK( ImplHandleLayoutTimerHdl, Timer*, void ); + + // try to extract content and return as Bitmap. To do that reliably, a Yield-loop + // like in Execute() has to be executed and it is necessary to detect when the + // paint is finished + virtual void PrePaint(vcl::RenderContext& rRenderContext) override; + virtual void PostPaint(vcl::RenderContext& rRenderContext) override; + + // ensureRepaint - triggers Application::Yield until the dialog is + // completely repainted. Sometimes needed for dialogs showing progress + // during actions + SAL_DLLPRIVATE void ensureRepaint(); + +protected: + // Single argument ctors shall be explicit. + explicit SystemWindow(WindowType nType); + void loadUI(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>()); + + void SetWindowStateData( const WindowStateData& rData ); + + virtual void settingOptimalLayoutSize(Window *pBox); + + SAL_DLLPRIVATE void DoInitialLayout(); + + SAL_DLLPRIVATE void SetIdleDebugName( const char *pDebugName ); + +public: + virtual ~SystemWindow() override; + virtual void dispose() override; + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + virtual bool Close(); + virtual void TitleButtonClick( TitleButton nButton ); + virtual void Resizing( Size& rSize ); + virtual void Resize() override; + virtual Size GetOptimalSize() const override; + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + bool isLayoutEnabled() const; + void setOptimalLayoutSize(); + bool isCalculatingInitialLayoutSize() const { return mbIsCalculatingInitialLayoutSize; } + + void SetIcon( sal_uInt16 nIcon ); + sal_uInt16 GetIcon() const { return mnIcon; } + // for systems like MacOSX which can display the URL a document is loaded from + // separately from the window title + void SetRepresentedURL( const OUString& ); + + void ShowTitleButton( TitleButton nButton, bool bVisible ); + bool IsTitleButtonVisible( TitleButton nButton ) const; + + void RollUp(); + void RollDown(); + bool IsRollUp() const { return mbRollUp; } + + void SetRollUpOutputSizePixel( const Size& rSize ) { maRollUpOutSize = rSize; } + const Size& GetRollUpOutputSizePixel() const { return maRollUpOutSize; } + + void SetMinOutputSizePixel( const Size& rSize ); + const Size& GetMinOutputSizePixel() const { return maMinOutSize; } + void SetMaxOutputSizePixel( const Size& rSize ); + const Size& GetMaxOutputSizePixel() const; + + void SetWindowState(const OString& rStr); + OString GetWindowState(WindowStateMask nMask = WindowStateMask::All) const; + + void SetMenuBar(MenuBar* pMenuBar); + MenuBar* GetMenuBar() const { return mpMenuBar; } + void SetMenuBarMode( MenuBarMode nMode ); + + void SetNotebookBar(const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame>& rFrame, + const NotebookBarAddonsItem& aNotebookBarAddonsItem, + bool bReloadNotebookbar = false); + + void CloseNotebookBar(); + VclPtr<NotebookBar> const & GetNotebookBar() const; + + TaskPaneList* GetTaskPaneList(); + void GetWindowStateData( WindowStateData& rData ) const; + + virtual void SetText( const OUString& rStr ) override; + virtual OUString GetText() const override; + + /** + Returns the screen number the window is on + + The Display Screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code> + and of course <code>SystemWindow::SetScreenNumber</code> + are counted in. + + In case the window is positioned on multiple screens the + screen number returned will be of the screen containing the + upper left pixel of the frame area (that is of the client + area on system decorated windows, or the frame area of + undecorated resp. owner decorated windows. + + @returns the screen number + + @see SystemWindow::SetScreenNumber + */ + unsigned int GetScreenNumber() const; + /** + Move the Window to a new screen. The same rules for + positioning apply as in <code>SystemWindow::GetScreenNumber</code> + + The Display Screen number is counted the same way that + <code>Application::GetScreenPosSizePixel</code> + and of course <code>SystemWindow::GetScreenNumber</code> + are counted in. + + @see GetScreenNumber + */ + void SetScreenNumber( unsigned int nNewScreen ); + + void SetApplicationID( const OUString &rApplicationID ); + + void SetCloseHdl(const Link<SystemWindow&,void>& rLink); + const Link<SystemWindow&,void>& GetCloseHdl() const; + + SAL_DLLPRIVATE bool hasPendingLayout() const { return maLayoutIdle.IsActive(); } + + virtual void doDeferredInit(WinBits nBits); + + // Screenshot interface + void createScreenshot(VirtualDevice& rOutput); +}; + +inline void SystemWindow::SetIdleDebugName( const char *pDebugName ) +{ + maLayoutIdle.SetDebugName( pDebugName ); +} + +#endif // INCLUDED_VCL_SYSWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/tabctrl.hxx b/include/vcl/tabctrl.hxx new file mode 100644 index 000000000..d35f0d76a --- /dev/null +++ b/include/vcl/tabctrl.hxx @@ -0,0 +1,228 @@ +/* -*- 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_TABCTRL_HXX +#define INCLUDED_VCL_TABCTRL_HXX + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/EnumContext.hxx> +#include <vcl/NotebookbarContextControl.hxx> +#include <boost/property_tree/json_parser.hpp> + +class ImplTabItem; +struct ImplTabCtrlData; +class TabPage; +class Button; +class PushButton; +class ListBox; + +#ifndef TAB_APPEND +#define TAB_APPEND (sal_uInt16(0xFFFF)) +#define TAB_PAGE_NOTFOUND (sal_uInt16(0xFFFF)) +#endif /* !TAB_APPEND */ + +#define TAB_OFFSET 3 +#define TAB_TABOFFSET_X 3 +#define TAB_TABOFFSET_Y 3 +#define TAB_EXTRASPACE_X 6 +#define TAB_BORDER_LEFT 1 +#define TAB_BORDER_TOP 1 +#define TAB_BORDER_RIGHT 2 +#define TAB_BORDER_BOTTOM 2 + +class VCL_DLLPUBLIC TabControl : public Control +{ +protected: + std::unique_ptr<ImplTabCtrlData> mpTabCtrlData; + long mnLastWidth; + long mnLastHeight; + sal_uInt16 mnActPageId; + sal_uInt16 mnCurPageId; + bool mbFormat; + bool mbRestoreHelpId; + bool mbSmallInvalidate; + bool mbLayoutDirty; + Link<TabControl*,void> maActivateHdl; + Link<TabControl*,bool> maDeactivateHdl; + + using Control::ImplInitSettings; + SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); + SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const; + SAL_DLLPRIVATE ImplTabItem* ImplGetItem(const Point& rPt) const; + SAL_DLLPRIVATE Size ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ); + SAL_DLLPRIVATE tools::Rectangle ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 ); + SAL_DLLPRIVATE tools::Rectangle ImplGetTabRect(const ImplTabItem*, long nWidth = -1, long nHeight = -1); + SAL_DLLPRIVATE void ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId ); + SAL_DLLPRIVATE bool ImplPosCurTabPage(); + virtual void ImplActivateTabPage( bool bNext ); + SAL_DLLPRIVATE void ImplShowFocus(); + SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplTabItem const * pItem, + const tools::Rectangle& rCurRect, bool bFirstInGroup, + bool bLastInGroup); + SAL_DLLPRIVATE void ImplFreeLayoutData(); + SAL_DLLPRIVATE bool ImplHandleKeyEvent( const KeyEvent& rKeyEvent ); + + DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl, ListBox&, void ); + DECL_DLLPRIVATE_LINK( ImplWindowEventListener, VclWindowEvent&, void ); + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + virtual void FillLayoutData() const override; + virtual const vcl::Font& GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + virtual bool ImplPlaceTabs( long nWidth ); + SAL_DLLPRIVATE Size ImplCalculateRequisition(sal_uInt16& nHeaderHeight) const; + +public: + TabControl( vcl::Window* pParent, + WinBits nStyle = WB_STDTABCONTROL ); + virtual ~TabControl() override; + virtual void dispose() override; + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + + virtual void ActivatePage(); + bool DeactivatePage(); + + virtual Size GetOptimalSize() const override; + + void SetTabPageSizePixel( const Size& rSize ); + + // pixel offset for the tab items, default is (0,0) + void SetItemsOffset( const Point& rOffs ); + Point GetItemsOffset() const; + + void InsertPage( sal_uInt16 nPageId, const OUString& rText, + sal_uInt16 nPos = TAB_APPEND ); + void RemovePage( sal_uInt16 nPageId ); + + void SetPageEnabled(sal_uInt16 nPageId, bool bEnable = true); + void SetPageVisible(sal_uInt16 nPageId, bool bVisible = true); + + sal_uInt16 GetPagePos( sal_uInt16 nPageId ) const; + sal_uInt16 GetPageCount() const; + sal_uInt16 GetPageId( sal_uInt16 nPos ) const; + sal_uInt16 GetPageId(const Point& rPos) const; + sal_uInt16 GetPageId( const OString& rName ) const; + + void SetCurPageId(sal_uInt16 nPageId); + sal_uInt16 GetCurPageId() const; + + void SelectTabPage( sal_uInt16 nPageId ); + + void SetTabPage(sal_uInt16 nPageId, TabPage* pPage); + TabPage* GetTabPage( sal_uInt16 nPageId ) const; + + void SetPageText( sal_uInt16 nPageId, const OUString& rText ); + OUString const & GetPageText( sal_uInt16 nPageId ) const; + + void SetHelpText( sal_uInt16 nPageId, const OUString& rText ); + const OUString& GetHelpText( sal_uInt16 nPageId ) const; + + void SetPageName( sal_uInt16 nPageId, const OString& rName ) const; + OString GetPageName( sal_uInt16 nPageId ) const; + + void SetPageImage( sal_uInt16 nPageId, const Image& rImage ); + + using Control::SetHelpId; + using Control::GetHelpId; + + void SetActivatePageHdl( const Link<TabControl*,void>& rLink ) { maActivateHdl = rLink; } + void SetDeactivatePageHdl( const Link<TabControl*, bool>& rLink ) { maDeactivateHdl = rLink; } + + // returns (control relative) bounding rectangle for the + // character at index nIndex relative to the text of page nPageId + using Control::GetCharacterBounds; + tools::Rectangle GetCharacterBounds( sal_uInt16 nPageId, long nIndex ) const; + + // returns the index relative to the text of page nPageId (also returned) + // at position rPoint (control relative) + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const; + + // returns the rectangle of the tab for page nPageId + tools::Rectangle GetTabBounds( sal_uInt16 nPageId ) const; + + virtual void SetPosPixel(const Point& rPos) override; + virtual void SetSizePixel(const Size& rNewSize) override; + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override; + + virtual Size calculateRequisition() const; + void setAllocation(const Size &rAllocation); + + std::vector<sal_uInt16> GetPageIDs() const; + + virtual FactoryFunction GetUITestFactory() const override; + + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +}; + +class NotebookBar; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) NotebookbarTabControlBase : public TabControl, + public NotebookbarContextControl +{ +public: + NotebookbarTabControlBase( vcl::Window* pParent ); + ~NotebookbarTabControlBase() override; + void dispose() override; + + void SetContext( vcl::EnumContext::Context eContext ) override; + void SetIconClickHdl( Link<NotebookBar*, void> aHdl ); + void SetToolBox( ToolBox* pToolBox ); + ToolBox* GetToolBox() { return m_pShortcuts; } + PushButton* GetOpenMenu() { return m_pOpenMenu; } + + virtual Size calculateRequisition() const override; + static sal_uInt16 GetHeaderHeight(); + +protected: + virtual bool ImplPlaceTabs( long nWidth ) override; + virtual void ImplActivateTabPage( bool bNext ) override; + +private: + bool bLastContextWasSupported; + vcl::EnumContext::Context eLastContext; + Link<NotebookBar*,void> m_aIconClickHdl; + static sal_uInt16 m_nHeaderHeight; + VclPtr<ToolBox> m_pShortcuts; + VclPtr<PushButton> m_pOpenMenu; + DECL_LINK(OpenMenu, Button*, void); +}; + +#endif // INCLUDED_VCL_TABCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/tabpage.hxx b/include/vcl/tabpage.hxx new file mode 100644 index 000000000..0dc11e4a5 --- /dev/null +++ b/include/vcl/tabpage.hxx @@ -0,0 +1,59 @@ +/* -*- 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_TABPAGE_HXX +#define INCLUDED_VCL_TABPAGE_HXX + +#include <vcl/dllapi.h> +#include <vcl/builder.hxx> +#include <vcl/window.hxx> +#include <vcl/IContext.hxx> + +class VCL_DLLPUBLIC TabPage + : public vcl::Window + , public VclBuilderContainer + , public vcl::IContext +{ +private: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings(); + +public: + explicit TabPage( vcl::Window* pParent, WinBits nStyle = 0 ); + explicit TabPage( vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription ); + virtual ~TabPage() override; + virtual void dispose() override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + //To-Do, consider inheriting from VclContainer + virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) override; + virtual void SetPosPixel(const Point& rNewPos) override; + virtual void SetSizePixel(const Size& rNewSize) override; + virtual Size GetOptimalSize() const override; +}; + +#endif // INCLUDED_VCL_TABPAGE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx new file mode 100644 index 000000000..35efe4825 --- /dev/null +++ b/include/vcl/task.hxx @@ -0,0 +1,104 @@ +/* -*- 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_TASK_HXX +#define INCLUDED_VCL_TASK_HXX + +#include <vcl/dllapi.h> + +struct ImplSchedulerData; + +enum class TaskPriority +{ + HIGHEST, ///< These events should run very fast! + DEFAULT, ///< Default priority used, e.g. the default timer priority + HIGH_IDLE, ///< Important idle events to be run before processing drawing events + RESIZE, ///< Resize runs before repaint, so we won't paint twice + REPAINT, ///< All repaint events should go in here + POST_PAINT, ///< Everything running directly after painting + DEFAULT_IDLE, ///< Default idle priority + LOWEST ///< Low, very idle cleanup tasks +}; + +#define PRIO_COUNT (static_cast<int>(TaskPriority::LOWEST) + 1) + +class VCL_DLLPUBLIC Task +{ + friend class Scheduler; + friend struct ImplSchedulerData; + + ImplSchedulerData *mpSchedulerData; ///< Pointer to the element in scheduler list + const char *mpDebugName; ///< Useful for debugging + TaskPriority mePriority; ///< Task priority + bool mbActive; ///< Currently in the scheduler + bool mbStatic; ///< Is a static object + +protected: + static void StartTimer( sal_uInt64 nMS ); + + const ImplSchedulerData* GetSchedulerData() const { return mpSchedulerData; } + + virtual void SetDeletionFlags(); + + /** + * How long (in MS) until the Task is ready to be dispatched? + * + * Simply return Scheduler::ImmediateTimeoutMs if you're ready, like an + * Idle. If you have to return Scheduler::InfiniteTimeoutMs, you probably + * need another mechanism to wake up the Scheduler or rely on other + * Tasks to be scheduled, or simply use a polling Timer. + * + * @param nTimeNow the current time + * @return the sleep time of the Task to become ready + */ + virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nTimeNow ) const = 0; + +public: + Task( const char *pDebugName ); + Task( const Task& rTask ); + virtual ~Task() COVERITY_NOEXCEPT_FALSE; + Task& operator=( const Task& rTask ); + + void SetPriority(TaskPriority ePriority); + TaskPriority GetPriority() const { return mePriority; } + + void SetDebugName( const char *pDebugName ) { mpDebugName = pDebugName; } + const char *GetDebugName() const { return mpDebugName; } + + // Call handler + virtual void Invoke() = 0; + + virtual void Start(); + void Stop(); + + bool IsActive() const { return mbActive; } + + /** + * This function must be called for static tasks, so the Task destructor + * ignores the SchedulerMutex, as it may not be available anymore. + * The cleanup is still correct, as it has already happened in + * DeInitScheduler call well before the static destructor calls. + */ + void SetStatic() { mbStatic = true; } + bool IsStatic() const { return mbStatic; } +}; + +#endif // INCLUDED_VCL_TASK_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/taskpanelist.hxx b/include/vcl/taskpanelist.hxx new file mode 100644 index 000000000..c055882e7 --- /dev/null +++ b/include/vcl/taskpanelist.hxx @@ -0,0 +1,54 @@ +/* -*- 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_TASKPANELIST_HXX +#define INCLUDED_VCL_TASKPANELIST_HXX + +#include <vcl/dllapi.h> + +#include <vector> +#include <vcl/keycod.hxx> +#include <vcl/vclptr.hxx> + +class KeyEvent; + +namespace vcl { class Window; } + +class VCL_DLLPUBLIC TaskPaneList +{ + ::std::vector< VclPtr<vcl::Window> > mTaskPanes; + vcl::Window *FindNextFloat( vcl::Window *pWindow, bool bForward ); + vcl::Window *FindNextSplitter( vcl::Window *pWindow ); + +public: + bool IsInList( vcl::Window *pWindow ); + +public: + TaskPaneList(); + ~TaskPaneList(); + + void AddWindow( vcl::Window *pWindow ); + void RemoveWindow( vcl::Window *pWindow ); + bool HandleKeyEvent(const KeyEvent& rKeyEvent); + static bool IsCycleKey(const vcl::KeyCode& rKeyCode); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/textdata.hxx b/include/vcl/textdata.hxx new file mode 100644 index 000000000..2e595fb89 --- /dev/null +++ b/include/vcl/textdata.hxx @@ -0,0 +1,144 @@ +/* -*- 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_TEXTDATA_HXX +#define INCLUDED_VCL_TEXTDATA_HXX + +#include <sal/types.h> +#include <tools/solar.h> +#include <rtl/ustring.hxx> +#include <svl/hint.hxx> +#include <vcl/dllapi.h> +#include <memory> + +enum class ExtTextInputAttr; + +// for Notify, if all paragraphs were deleted +#define TEXT_PARA_ALL SAL_MAX_UINT32 +#define TEXT_INDEX_ALL SAL_MAX_INT32 + +class TextPaM +{ +private: + sal_uInt32 mnPara; + sal_Int32 mnIndex; + +public: + TextPaM() : mnPara(0), mnIndex(0) {} + TextPaM( sal_uInt32 nPara, sal_Int32 nIndex ) : mnPara(nPara), mnIndex(nIndex) {} + + sal_uInt32 GetPara() const { return mnPara; } + sal_uInt32& GetPara() { return mnPara; } + + sal_Int32 GetIndex() const { return mnIndex; } + sal_Int32& GetIndex() { return mnIndex; } + + inline bool operator == ( const TextPaM& rPaM ) const; + inline bool operator != ( const TextPaM& rPaM ) const; + inline bool operator < ( const TextPaM& rPaM ) const; + inline bool operator > ( const TextPaM& rPaM ) const; +}; + +inline bool TextPaM::operator == ( const TextPaM& rPaM ) const +{ + return ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex ); +} + +inline bool TextPaM::operator != ( const TextPaM& rPaM ) const +{ + return !( *this == rPaM ); +} + +inline bool TextPaM::operator < ( const TextPaM& rPaM ) const +{ + return ( mnPara < rPaM.mnPara ) || + ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex ); +} + +inline bool TextPaM::operator > ( const TextPaM& rPaM ) const +{ + return ( mnPara > rPaM.mnPara ) || + ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex ); +} + +class VCL_DLLPUBLIC TextSelection +{ +private: + TextPaM maStartPaM; + TextPaM maEndPaM; + +public: + TextSelection(); + TextSelection( const TextPaM& rPaM ); + TextSelection( const TextPaM& rStart, const TextPaM& rEnd ); + + const TextPaM& GetStart() const { return maStartPaM; } + TextPaM& GetStart() { return maStartPaM; } + + const TextPaM& GetEnd() const { return maEndPaM; } + TextPaM& GetEnd() { return maEndPaM; } + + void Justify(); + + bool HasRange() const { return maStartPaM != maEndPaM; } + + inline bool operator == ( const TextSelection& rSel ) const; + inline bool operator != ( const TextSelection& rSel ) const; +}; + +inline bool TextSelection::operator == ( const TextSelection& rSel ) const +{ + return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) ); +} + +inline bool TextSelection::operator != ( const TextSelection& rSel ) const +{ + return !( *this == rSel ); +} + +class VCL_DLLPUBLIC TextHint : public SfxHint +{ +private: + sal_uLong mnValue; + +public: + TextHint( SfxHintId nId ); + TextHint( SfxHintId nId, sal_uLong nValue ); + + sal_uLong GetValue() const { return mnValue; } +}; + +struct TEIMEInfos +{ + OUString aOldTextAfterStartPos; + std::unique_ptr<ExtTextInputAttr[]> pAttribs; + TextPaM aPos; + sal_Int32 nLen; + bool bWasCursorOverwrite; + + TEIMEInfos(const TextPaM& rPos, const OUString& rOldTextAfterStartPos); + ~TEIMEInfos(); + + void CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL); + void DestroyAttribs(); +}; + +#endif // INCLUDED_VCL_TEXTDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx new file mode 100644 index 000000000..ee0ae62e0 --- /dev/null +++ b/include/vcl/texteng.hxx @@ -0,0 +1,306 @@ +/* -*- 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_TEXTENG_HXX +#define INCLUDED_VCL_TEXTENG_HXX + +#include <memory> +#include <sal/config.h> + +#include <cstddef> +#include <vector> + +#include <vcl/dllapi.h> +#include <vcl/vclptr.hxx> +#include <rtl/ustring.hxx> +#include <svl/SfxBroadcaster.hxx> +#include <tools/lineend.hxx> +#include <tools/link.hxx> +#include <tools/gen.hxx> +#include <tools/color.hxx> +#include <vcl/font.hxx> + +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/uno/Reference.hxx> + +class TextDoc; +class TextView; +class TextPaM; +class TextSelection; +class TEParaPortions; +class TextAttrib; +class TextCharAttrib; +class TextUndo; +class TextUndoManager; +class IdleFormatter; +class TextNode; +class OutputDevice; +class KeyEvent; +class Timer; +class SfxUndoManager; +class TextLine; +struct TEIMEInfos; + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XExtendedInputSequenceChecker; +}}}} + +class LocaleDataWrapper; + +enum class TxtAlign { Left, Center, Right }; + +typedef std::vector<TextView*> TextViews; + +class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster +{ + friend class TextView; + friend class TextSelFunctionSet; + friend class ExtTextEngine; + + friend class TextUndo; + friend class TextUndoManager; + friend class TextUndoDelPara; + friend class TextUndoConnectParas; + friend class TextUndoSplitPara; + friend class TextUndoInsertChars; + friend class TextUndoRemoveChars; + + std::unique_ptr<TextDoc> mpDoc; + std::unique_ptr<TEParaPortions> mpTEParaPortions; + VclPtr<OutputDevice> mpRefDev; + + std::unique_ptr<TextViews> mpViews; + TextView* mpActiveView; + + std::unique_ptr<TextUndoManager> mpUndoManager; + + std::unique_ptr<IdleFormatter> mpIdleFormatter; + + std::unique_ptr<TEIMEInfos> mpIMEInfos; + + css::lang::Locale maLocale; + css::uno::Reference< css::i18n::XBreakIterator > mxBreakIterator; + css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > mxISC; + + tools::Rectangle maInvalidRect; + + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; + + vcl::Font maFont; + Color maTextColor; + + sal_Int32 mnMaxTextLen; + long mnMaxTextWidth; + long mnCharHeight; + long mnCurTextWidth; + long mnCurTextHeight; + long mnDefTab; + + TxtAlign meAlign; + + bool mbIsFormatting : 1; // semaphore for the Hook's + bool mbFormatted : 1; + bool mbUpdate : 1; + bool mbModified : 1; + bool mbUndoEnabled : 1; + bool mbIsInUndo : 1; + bool mbDowning : 1; + bool mbRightToLeft : 1; + bool mbHasMultiLineParas : 1; + + void CursorMoved( sal_uInt32 nNode ); + void TextModified(); + + void ImpInitDoc(); + void ImpRemoveText(); + TextPaM ImpDeleteText( const TextSelection& rSel ); + TextPaM ImpInsertText( const TextSelection& rSel, sal_Unicode c, bool bOverwrite = false ); + TextPaM ImpInsertText( const TextSelection& rSel, const OUString& rText ); + TextPaM ImpInsertParaBreak( const TextSelection& rTextSelection ); + TextPaM ImpInsertParaBreak( const TextPaM& rPaM ); + void ImpRemoveChars( const TextPaM& rPaM, sal_Int32 nChars ); + TextPaM ImpConnectParagraphs( sal_uInt32 nLeft, sal_uInt32 nRight ); + void ImpRemoveParagraph( sal_uInt32 nPara ); + void ImpInitWritingDirections( sal_uInt32 nPara ); + LocaleDataWrapper* ImpGetLocaleDataWrapper(); + + // to remain compatible in the minor release we copy the above ImpInsertText + // function and add the extra parameter we need but make sure this function + // gets not exported. First and second parameter swapped to have a different signature. + SAL_DLLPRIVATE TextPaM ImpInsertText( sal_Unicode c, const TextSelection& rSel, bool bOverwrite, bool bIsUserInput = false ); + // some other new functions needed that must not be exported to remain compatible + SAL_DLLPRIVATE css::uno::Reference< css::i18n::XExtendedInputSequenceChecker > const & GetInputSequenceChecker(); + SAL_DLLPRIVATE bool IsInputSequenceCheckingRequired( sal_Unicode c, const TextSelection& rCurSel ) const; + + // broadcast or adjust selections + void ImpParagraphInserted( sal_uInt32 nPara ); + void ImpParagraphRemoved( sal_uInt32 nPara ); + void ImpCharsRemoved( sal_uInt32 nPara, sal_Int32 nPos, sal_Int32 nChars ); + void ImpCharsInserted( sal_uInt32 nPara, sal_Int32 nPos, sal_Int32 nChars ); + + DECL_LINK( IdleFormatHdl, Timer *, void ); + void CheckIdleFormatter(); + void IdleFormatAndUpdate( TextView* pCurView, sal_uInt16 nMaxTimerRestarts = 5 ); + + bool CreateLines( sal_uInt32 nPara ); + void CreateAndInsertEmptyLine( sal_uInt32 nPara ); + void ImpBreakLine( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nPortionStart, long nRemainingWidth ); + std::size_t SplitTextPortion( sal_uInt32 nPara, sal_Int32 nPos ); + void CreateTextPortions( sal_uInt32 nPara, sal_Int32 nStartPos ); + void RecalcTextPortion( sal_uInt32 nPara, sal_Int32 nStartPos, sal_Int32 nNewChars ); + void SeekCursor( sal_uInt32 nNode, sal_Int32 nPos, vcl::Font& rFont, OutputDevice* pOutDev ); + + void FormatDoc(); + void FormatFullDoc(); + void FormatAndUpdate( TextView* pCurView = nullptr ); + bool IsFormatting() const { return mbIsFormatting; } + void UpdateViews( TextView* pCurView = nullptr ); + + void ImpPaint( OutputDevice* pOut, const Point& rStartPos, tools::Rectangle const* pPaintArea, TextSelection const* pSelection = nullptr ); + + bool IsFormatted() const { return mbFormatted; } + + sal_Int32 GetCharPos( sal_uInt32 nPara, std::vector<TextLine>::size_type nLine, long nDocPosX ); + tools::Rectangle GetEditCursor( const TextPaM& rPaM, bool bSpecial, bool bPreferPortionStart = false ); + sal_Int32 ImpFindIndex( sal_uInt32 nPortion, const Point& rPosInPara ); + long ImpGetPortionXOffset( sal_uInt32 nPara, TextLine const * pLine, std::size_t nTextPortion ); + long ImpGetXPos( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false ); + long ImpGetOutputOffset( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex, sal_Int32 nIndex2 ); + bool ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos ); + static void ImpInitLayoutMode( OutputDevice* pOutDev ); + TxtAlign ImpGetAlign() const; + + long CalcTextHeight(); + long CalcParaHeight( sal_uInt32 nParagraph ) const; + long CalcTextWidth( sal_uInt32 nPara ); + long CalcTextWidth( sal_uInt32 nPara, sal_Int32 nPortionStart, sal_Int32 nPortionLen); + Range GetInvalidYOffsets( sal_uInt32 nPortion ); + + // for Undo/Redo + void InsertContent( std::unique_ptr<TextNode> pNode, sal_uInt32 nPara ); + TextPaM SplitContent( sal_uInt32 nNode, sal_Int32 nSepPos ); + TextPaM ConnectContents( sal_uInt32 nLeftNode ); + + // adjust PaM's and selections that were transferred to the API to a valid range + void ValidateSelection( TextSelection& rSel ) const; + void ValidatePaM( TextPaM& rPaM ) const; + +public: + TextEngine(); + virtual ~TextEngine() override; + TextEngine( const TextEngine& ) = delete; + TextEngine& operator=( const TextEngine& ) = delete; + + void SetText( const OUString& rStr ); + OUString GetText( LineEnd aSeparator = LINEEND_LF ) const; + OUString GetText( const TextSelection& rSel, LineEnd aSeparator = LINEEND_LF ) const; + OUString GetTextLines( LineEnd aSeparator = LINEEND_LF ) const; + void ReplaceText(const TextSelection& rSel, const OUString& rText); + + sal_Int32 GetTextLen() const; + sal_Int32 GetTextLen( const TextSelection& rSel ) const; + + void SetFont( const vcl::Font& rFont ); + const vcl::Font& GetFont() const { return maFont; } + + void SetLeftMargin( sal_uInt16 n ); + + void SetUpdateMode( bool bUpdate ); + bool GetUpdateMode() const { return mbUpdate; } + + sal_uInt16 GetViewCount() const; + TextView* GetView( sal_uInt16 nView ) const; + void InsertView( TextView* pTextView ); + void RemoveView( TextView* pTextView ); + TextView* GetActiveView() const { return mpActiveView;} + void SetActiveView( TextView* pView ); + + void SetMaxTextLen( sal_Int32 nLen ); + sal_Int32 GetMaxTextLen() const { return mnMaxTextLen; } + + void SetMaxTextWidth( long nWidth ); + long GetMaxTextWidth() const { return mnMaxTextWidth; } + + long GetTextHeight() const; + long CalcTextWidth(); + long GetCharHeight() const { return mnCharHeight; } + + sal_uInt32 GetParagraphCount() const; + OUString GetText( sal_uInt32 nParagraph ) const; + sal_Int32 GetTextLen( sal_uInt32 nParagraph ) const; + long GetTextHeight( sal_uInt32 nParagraph ) const; + + void GetTextPortionRange(const TextPaM& rPaM, sal_Int32& nStart, sal_Int32& nEnd); + + sal_uInt16 GetLineCount( sal_uInt32 nParagraph ) const; + sal_Int32 GetLineLen( sal_uInt32 nParagraph, sal_uInt16 nLine ) const; + + void SetRightToLeft( bool bR2L ); + bool IsRightToLeft() const { return mbRightToLeft; } + + bool HasUndoManager() const { return mpUndoManager != nullptr; } + SfxUndoManager& GetUndoManager(); + void UndoActionStart( sal_uInt16 nId = 0 ); + void UndoActionEnd(); + void InsertUndo( std::unique_ptr<TextUndo> pUndo, bool bTryMerge = false ); + bool IsInUndo() const { return mbIsInUndo; } + void SetIsInUndo( bool bInUndo ) { mbIsInUndo = bInUndo; } + void ResetUndo(); + + void EnableUndo( bool bEnable ); + bool IsUndoEnabled() const { return mbUndoEnabled; } + + void SetModified( bool bModified ) { mbModified = bModified; } + bool IsModified() const { return mbModified; } + + bool Read( SvStream& rInput, const TextSelection* pSel = nullptr ); + + void Write( SvStream& rOutput ); + + TextPaM GetPaM( const Point& rDocPos ); + tools::Rectangle PaMtoEditCursor( const TextPaM& rPaM, bool bSpecial = false ); + OUString GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord = nullptr, TextPaM* pEndOfWord = nullptr ); + + const TextAttrib* FindAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const; + const TextCharAttrib* FindCharAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const; + + void RemoveAttribs( sal_uInt32 nPara ); + void SetAttrib( const TextAttrib& rAttr, sal_uInt32 nPara, sal_Int32 nStart, sal_Int32 nEnd ); + + TxtAlign GetTextAlign() const { return meAlign; } + void SetTextAlign( TxtAlign eAlign ); + + void Draw( OutputDevice* pDev, const Point& rPos ); + + void SetLocale( const css::lang::Locale& rLocale ); + css::lang::Locale const & GetLocale(); + css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIterator(); + + static bool DoesKeyChangeText( const KeyEvent& rKeyEvent ); + static bool IsSimpleCharInput( const KeyEvent& rKeyEvent ); + + const Color& GetTextColor() const { return maTextColor; } +}; + +#endif // INCLUDED_VCL_TEXTENG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/textfilter.hxx b/include/vcl/textfilter.hxx new file mode 100644 index 000000000..603daafd9 --- /dev/null +++ b/include/vcl/textfilter.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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_TEXTFILTER_HXX +#define INCLUDED_VCL_TEXTFILTER_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> + +class VCL_DLLPUBLIC TextFilter +{ +private: + OUString sForbiddenChars; + +public: + void SetForbiddenChars(const OUString& rSet) { sForbiddenChars = rSet; } + + virtual OUString filter(const OUString& rText); + + TextFilter(const OUString& rForbiddenChars = OUString(" ")); + virtual ~TextFilter(); +}; + +#endif // INCLUDED_VCL_TEXTFILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/include/vcl/textrectinfo.hxx b/include/vcl/textrectinfo.hxx new file mode 100644 index 000000000..c13d65e80 --- /dev/null +++ b/include/vcl/textrectinfo.hxx @@ -0,0 +1,58 @@ +/* -*- 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_TEXTRECTINFO_HXX +#define INCLUDED_VCL_TEXTRECTINFO_HXX + +#include <vcl/dllapi.h> +class OutputDevice; + +class VCL_DLLPUBLIC TextRectInfo +{ + friend class ::OutputDevice; + +private: + long mnMaxWidth; + sal_uInt16 mnLineCount; + bool mbEllipsis; + +public: + TextRectInfo(); + + long GetMaxLineWidth() const { return mnMaxWidth; } + bool IsEllipses() const { return mbEllipsis; } + + bool operator ==( const TextRectInfo& rInfo ) const + { return ((mnMaxWidth == rInfo.mnMaxWidth) && + (mnLineCount == rInfo.mnLineCount) && + (mbEllipsis == rInfo.mbEllipsis)); } + bool operator !=( const TextRectInfo& rInfo ) const + { return !(TextRectInfo::operator==( rInfo )); } +}; + +inline TextRectInfo::TextRectInfo() +{ + mnMaxWidth = 0; + mnLineCount = 0; + mbEllipsis = false; +} + +#endif // INCLUDED_VCL_TEXTRECTINFO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/textview.hxx b/include/vcl/textview.hxx new file mode 100644 index 000000000..bf0ea21ec --- /dev/null +++ b/include/vcl/textview.hxx @@ -0,0 +1,229 @@ +/* -*- 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_TEXTVIEW_HXX +#define INCLUDED_VCL_TEXTVIEW_HXX + +#include <config_options.h> +#include <tools/gen.hxx> +#include <tools/lineend.hxx> +#include <tools/stream.hxx> +#include <vcl/dllapi.h> +#include <vcl/dndhelp.hxx> +#include <vcl/textdata.hxx> +#include <vcl/outdev.hxx> +#include <memory> + +class TextEngine; + +class KeyEvent; +class MouseEvent; +class CommandEvent; +namespace vcl { class Window; } + +namespace com::sun::star::datatransfer::clipboard { + class XClipboard; +} +namespace i18nutil { + struct SearchOptions; +} + + +struct ImpTextView; +class ExtTextEngine; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TETextDataObject final : public css::datatransfer::XTransferable, + public ::cppu::OWeakObject + +{ +private: + OUString maText; + SvMemoryStream maHTMLStream; + +public: + explicit TETextDataObject( const OUString& rText ); + + SvMemoryStream& GetHTMLStream() { return maHTMLStream; } + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() throw() override { OWeakObject::acquire(); } + void SAL_CALL release() throw() override { OWeakObject::release(); } + + // css::datatransfer::XTransferable + css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override; + css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override; + sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override; +}; + + +class VCL_DLLPUBLIC TextView final : public vcl::unohelper::DragAndDropClient +{ + friend class TextEngine; + friend class TextUndo; + friend class TextUndoManager; + friend class TextSelFunctionSet; + + std::unique_ptr<ImpTextView> mpImpl; + + TextView( const TextView& ) = delete; + TextView& operator=( const TextView& ) = delete; + + bool ImpIndentBlock( bool bRight ); + void ShowSelection(); + void HideSelection(); + void ShowSelection( const TextSelection& rSel ); + void ImpShowHideSelection( const TextSelection* pRange = nullptr ); + + TextSelection const & ImpMoveCursor( const KeyEvent& rKeyEvent ); + TextPaM ImpDelete( sal_uInt8 nMode, sal_uInt8 nDelMode ); + bool IsInSelection( const TextPaM& rPaM ); + + void ImpPaint(vcl::RenderContext& rRenderContext, const Point& rStartPos, tools::Rectangle const* pPaintArea, TextSelection const* pSelection); + void ImpPaint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + void ImpShowCursor( bool bGotoCursor, bool bForceVisCursor, bool bEndKey ); + void ImpHighlight( const TextSelection& rSel ); + void ImpSetSelection( const TextSelection& rSelection ); + Point ImpGetOutputStartPos( const Point& rStartDocPos ) const; + + void ImpHideDDCursor(); + void ImpShowDDCursor(); + + bool ImplTruncateNewText( OUString& rNewText ) const; + bool ImplCheckTextLen( const OUString& rNewText ); + + // DragAndDropClient + virtual void dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& dge ) override; + virtual void dragDropEnd( const css::datatransfer::dnd::DragSourceDropEvent& dsde ) override; + virtual void drop( const css::datatransfer::dnd::DropTargetDropEvent& dtde ) override; + virtual void dragEnter( const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) override; + virtual void dragExit( const css::datatransfer::dnd::DropTargetEvent& dte ) override; + virtual void dragOver( const css::datatransfer::dnd::DropTargetDragEvent& dtde ) override; + + using DragAndDropClient::dragEnter; + using DragAndDropClient::dragExit; + using DragAndDropClient::dragOver; + +public: + TextView( ExtTextEngine* pEng, vcl::Window* pWindow ); + virtual ~TextView() override; + + TextEngine* GetTextEngine() const; + vcl::Window* GetWindow() const; + + void Invalidate(); + void Scroll( long nHorzScroll, long nVertScroll ); + + void ShowCursor( bool bGotoCursor = true, bool bForceVisCursor = true ); + void HideCursor(); + + void EnableCursor( bool bEnable ); + bool IsCursorEnabled() const; + + const TextSelection& GetSelection() const; + TextSelection& GetSelection(); + void SetSelection( const TextSelection& rNewSel ); + void SetSelection( const TextSelection& rNewSel, bool bGotoCursor ); + bool HasSelection() const; + + OUString GetSelected(); + OUString GetSelected( LineEnd aSeparator ); + void DeleteSelected(); + + void InsertText( const OUString& rNew ); + + bool KeyInput( const KeyEvent& rKeyEvent ); + void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + void MouseButtonUp( const MouseEvent& rMouseEvent ); + void MouseButtonDown( const MouseEvent& rMouseEvent ); + void MouseMove( const MouseEvent& rMouseEvent ); + void Command( const CommandEvent& rCEvt ); + + void Cut(); + void Copy(); + void Paste(); + + void Copy( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard ); + void Paste( css::uno::Reference< css::datatransfer::clipboard::XClipboard > const & rxClipboard ); + + void Undo(); + void Redo(); + + void Read( SvStream& rInput ); + + void SetStartDocPos( const Point& rPos ); + const Point& GetStartDocPos() const; + + Point GetDocPos( const Point& rWindowPos ) const; + Point GetWindowPos( const Point& rDocPos ) const; + + void SetInsertMode( bool bInsert ); + bool IsInsertMode() const; + + void SetAutoIndentMode( bool bAutoIndent ); + + void SetReadOnly( bool bReadOnly ); + bool IsReadOnly() const; + + void SetAutoScroll( bool bAutoScroll ); + bool IsAutoScroll() const; + + void SetCursorAtPoint( const Point& rPointPixel ); + bool IsSelectionAtPoint( const Point& rPointPixel ); + + void SetPaintSelection( bool bPaint); + + // Moved in here from the protected part. + // For 'SvtXECTextCursor' (TL). Possibly needs to be solved again differently. + TextPaM PageUp( const TextPaM& rPaM ); + TextPaM PageDown( const TextPaM& rPaM ); + TextPaM CursorUp( const TextPaM& rPaM ); + TextPaM CursorDown( const TextPaM& rPaM ); + TextPaM CursorLeft( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); + TextPaM CursorRight( const TextPaM& rPaM, sal_uInt16 nCharacterIteratorMode ); + TextPaM CursorWordLeft( const TextPaM& rPaM ); + TextPaM CursorWordRight( const TextPaM& rPaM ); + TextPaM CursorStartOfLine( const TextPaM& rPaM ); + TextPaM CursorEndOfLine( const TextPaM& rPaM ); + static TextPaM CursorStartOfParagraph( const TextPaM& rPaM ); + TextPaM CursorEndOfParagraph( const TextPaM& rPaM ); + static TextPaM CursorStartOfDoc(); + TextPaM CursorEndOfDoc(); + + /** + Returns the number in paragraph of the line in which the cursor is blinking + if enabled, -1 otherwise. + */ + sal_Int32 GetLineNumberOfCursorInSelection() const; + + void MatchGroup(); + + // tdf#49482: Moves the start of the PaM to the center of the textview + void CenterPaM( const TextPaM& rPaM ); + + bool Search( const i18nutil::SearchOptions& rSearchOptions, bool bForward ); + sal_uInt16 Replace( const i18nutil::SearchOptions& rSearchOptions, bool bAll, bool bForward ); + + bool IndentBlock(); + bool UnindentBlock(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/threadex.hxx b/include/vcl/threadex.hxx new file mode 100644 index 000000000..af2978ce3 --- /dev/null +++ b/include/vcl/threadex.hxx @@ -0,0 +1,174 @@ +/* -*- 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_THREADEX_HXX +#define INCLUDED_VCL_THREADEX_HXX + +#include <osl/conditn.hxx> +#include <tools/link.hxx> +#include <vcl/dllapi.h> + +#include <optional> +#include <memory> + +namespace vcl +{ + class VCL_DLLPUBLIC SolarThreadExecutor + { + osl::Condition m_aStart; + osl::Condition m_aFinish; + bool m_bTimeout; + + DECL_DLLPRIVATE_LINK( worker, void*, void ); + + public: + SolarThreadExecutor(); + virtual ~SolarThreadExecutor(); + + virtual void doIt() = 0; + void execute(); + }; + +namespace solarthread { + +/// @internal +namespace detail { + +template <typename FuncT, typename ResultT> +class GenericSolarThreadExecutor final : public SolarThreadExecutor +{ +public: + static ResultT exec( FuncT const& func ) + { + typedef GenericSolarThreadExecutor<FuncT, ResultT> ExecutorT; + ::std::unique_ptr<ExecutorT> const pExecutor( new ExecutorT(func) ); + pExecutor->execute(); + if (pExecutor->m_exc) + std::rethrow_exception(pExecutor->m_exc); + return *pExecutor->m_result; + } + +private: + explicit GenericSolarThreadExecutor( FuncT const& func ) + : m_func(func), m_result() {} + + virtual void doIt() override + { + try { + m_result = m_func(); + } + catch (...) { + m_exc = std::current_exception(); + } + } + + std::exception_ptr m_exc; +#ifdef _MSC_VER + FuncT m_func; // "const" and std::bind() results in Error C3848 expression would lose const-volatile qualifiers +#else + FuncT const m_func; +#endif + // using std::optional here omits the need that ResultT is default + // constructable: + ::std::optional<ResultT> m_result; +}; + +template <typename FuncT> +class GenericSolarThreadExecutor<FuncT, void> final : public SolarThreadExecutor +{ +public: + static void exec( FuncT const& func ) + { + typedef GenericSolarThreadExecutor<FuncT, void> ExecutorT; + ::std::unique_ptr<ExecutorT> const pExecutor( new ExecutorT(func) ); + pExecutor->execute(); + if (pExecutor->m_exc) + std::rethrow_exception(pExecutor->m_exc); + } + +private: + explicit GenericSolarThreadExecutor( FuncT const& func ) + : m_func(func) {} + + virtual void doIt() override + { + try { + m_func(); + } + catch (...) { + m_exc = std::current_exception(); + } + } + + std::exception_ptr m_exc; + FuncT const m_func; +}; + +} // namespace detail + + +/** This function will execute the passed functor synchronously in the + solar thread, thus the calling thread will (eventually) be blocked until + the functor has been called. + Any exception that came up calling the functor in the solar thread + will be caught and rethrown in the calling thread. + The result type of this function needs to be default constructable. + Please keep in mind not to pass addresses to stack variables + (e.g. for out parameters) to foreign threads, use inout_by_ref() + for this purpose. For in parameters, this may not affect you, because + the functor object is copy constructed into free store. This way + you must not use \verbatim std::cref()/std::ref() \endverbatim or similar + for objects on your thread's stack. + Use inout_by_ref() or inout_by_ptr() for this purpose, e.g. + + \code{.cpp} + using namespace vcl::solarthread; + + long n = 3; + // calling foo( long & r ): + syncExecute( std::bind( &foo, inout_by_ref(n) ) ); + // calling foo( long * p ): + syncExecute( std::bind( &foo, inout_by_ptr(&n) ) ); + + char const* pc = "default"; + // calling foo( char const** ppc ): + syncExecute( std::bind( &foo, inout_by_ptr(&pc) ) ); + // calling foo( char const*& rpc ): + syncExecute( std::bind( &foo, inout_by_ref(pc) ) ); + \endcode + + @tpl ResultT result type, defaults to FuncT::result_type to seamlessly + support mem_fn and bind + @tpl FuncT functor type, let your compiler deduce this type + @param func functor object to be executed in solar thread + @return return value of functor +*/ +template <typename FuncT> +inline auto syncExecute(FuncT const& func) -> decltype(func()) +{ + return detail::GenericSolarThreadExecutor< + FuncT, decltype(func())>::exec(func); +} + +} // namespace solarthread +} // namespace vcl + +#endif // INCLUDED_VCL_THREADEX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx new file mode 100644 index 000000000..d9ad82ee5 --- /dev/null +++ b/include/vcl/timer.hxx @@ -0,0 +1,83 @@ +/* -*- 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_TIMER_HXX +#define INCLUDED_VCL_TIMER_HXX + +#include <tools/link.hxx> +#include <vcl/task.hxx> + +class VCL_DLLPUBLIC Timer : public Task +{ + Link<Timer *, void> maInvokeHandler; ///< Callback Link + sal_uInt64 mnTimeout; + const bool mbAuto; + +protected: + virtual void SetDeletionFlags() override; + virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nTimeNow ) const override; + + Timer( bool bAuto, const char *pDebugName ); + +public: + Timer( const char *pDebugName = nullptr ); + Timer( const Timer& rTimer ); + virtual ~Timer() override; + Timer& operator=( const Timer& rTimer ); + + /** + * Calls the maInvokeHandler with the parameter this. + */ + virtual void Invoke() override; + /** + * Calls the maInvokeHandler with the parameter. + * + * Convenience Invoke function, mainly used to call with nullptr. + * + * @param arg parameter for the Link::Call function + */ + void Invoke( Timer *arg ); + void SetInvokeHandler( const Link<Timer *, void>& rLink ) { maInvokeHandler = rLink; } + void ClearInvokeHandler() { SetInvokeHandler( Link<Timer *, void>() ); } + + void SetTimeout( sal_uInt64 nTimeoutMs ); + sal_uInt64 GetTimeout() const { return mnTimeout; } + /** + * Activates the timer task + * + * If the timer is already active, it's reset! + * Check with Task::IsActive() to prevent reset. + */ + virtual void Start() override; +}; + +/// An auto-timer is a multi-shot timer re-emitting itself at +/// interval until destroyed or stopped. +class VCL_DLLPUBLIC AutoTimer : public Timer +{ +public: + AutoTimer( const char *pDebugName = nullptr ); +}; + +/// Value suitable as a timeout user input into an EditBox to an expensive update +#define EDIT_UPDATEDATA_TIMEOUT 350 + +#endif // INCLUDED_VCL_TIMER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx new file mode 100644 index 000000000..e60fb6429 --- /dev/null +++ b/include/vcl/toolbox.hxx @@ -0,0 +1,534 @@ +/* -*- 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_TOOLBOX_HXX +#define INCLUDED_VCL_TOOLBOX_HXX + +#include <vcl/vclenum.hxx> +#include <vcl/dllapi.h> +#include <vcl/dockwin.hxx> +#include <vcl/image.hxx> +#include <vcl/keycod.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <limits> +#include <memory> +#include <vector> + +namespace com::sun::star::frame { class XFrame; } +namespace com::sun::star::frame { struct FeatureStateEvent; } +template <class T> class VclStatusListener; + +class Timer; +struct ImplToolItem; +struct ImplToolBoxPrivateData; +class PopupMenu; +class VclMenuEvent; +class StyleSettings; + +constexpr sal_uInt16 TOOLBOX_STYLE_FLAT = 0x0004; + +// item ids in the custom menu may not exceed this constant +constexpr sal_uInt16 TOOLBOX_MENUITEM_START = 0x1000; + +// defines for the menubutton +enum class ToolBoxMenuType { + NONE = 0x0000, // no menu at all, scrolling by spin buttons + ClippedItems = 0x0001, // menu will contain "more" indicator + Customize = 0x0002 // menu will contain "customization" and "more" indicator +}; +namespace o3tl +{ + template<> struct typed_flags<ToolBoxMenuType> : is_typed_flags<ToolBoxMenuType, 0x0003> {}; +} + +enum class ToolBoxLayoutMode +{ + Normal, // traditional layout, items are centered in the toolbar + Locked // horizontal positions of all items remain unchanged, + // vertical positions of items smaller than first item are aligned to first item's vertical center, + // vertical positions of items larger than first item remain unchanged +}; + +// Position of the text when icon and text are painted +enum class ToolBoxTextPosition { Right, Bottom }; + +class Idle; +class VCL_DLLPUBLIC ToolBox : public DockingWindow +{ + friend class FloatingWindow; + friend class ImplTBDragMgr; + +public: + using ImplToolItems = std::vector<ImplToolItem>; + + static constexpr auto APPEND + = std::numeric_limits<ImplToolItems::size_type>::max(); + + static constexpr auto ITEM_NOTFOUND + = std::numeric_limits<ImplToolItems::size_type>::max(); + +private: + struct ImplToolSize + { + long mnWidth; + long mnHeight; + ImplToolItems::size_type mnLines; + }; + + std::unique_ptr<ImplToolBoxPrivateData> mpData; + std::vector<ImplToolSize> maFloatSizes; + std::unique_ptr<Idle> mpIdle; + tools::Rectangle maUpperRect; + tools::Rectangle maLowerRect; + tools::Rectangle maPaintRect; + VclPtr<FloatingWindow> mpFloatWin; + long mnDX; + long mnDY; + long mnMaxItemWidth; // max item width + long mnMaxItemHeight; // max item height (for standard items) + long mnWinHeight; // max window height (for window items) + long mnLeftBorder; // inner border + long mnTopBorder; + long mnRightBorder; + long mnBottomBorder; + long mnLastResizeDY; + long mnActivateCount; + long mnImagesRotationAngle; + sal_uInt16 mnLastFocusItemId; + sal_uInt16 mnOutStyle; + sal_uInt16 mnHighItemId; + sal_uInt16 mnCurItemId; + sal_uInt16 mnDownItemId; + ImplToolItems::size_type mnCurPos; + ImplToolItems::size_type mnLines; // total number of toolbox lines + ImplToolItems::size_type mnCurLine; // the currently visible line + ImplToolItems::size_type mnCurLines; // number of lines due to line breaking + ImplToolItems::size_type mnVisLines; // number of visible lines (for scrolling) + ImplToolItems::size_type mnFloatLines; // number of lines during floating mode + ImplToolItems::size_type mnDockLines; + sal_uInt16 mnMouseModifier; + bool mbDrag:1, + mbUpper:1, + mbLower:1, + mbIn:1, + mbCalc:1, + mbFormat:1, + mbFullPaint:1, + mbHorz:1, + mbScroll:1, + mbLastFloatMode:1, + mbCustomize:1, + mbDragging:1, + mbIsKeyEvent:1, + mbChangingHighlight:1, + mbImagesMirrored:1, + mbLineSpacing:1, + mbIsArranged:1; + WindowAlign meAlign; + WindowAlign meDockAlign; + ButtonType meButtonType; + PointerStyle meLastStyle; + WinBits mnWinStyle; + ToolBoxLayoutMode meLayoutMode; + ToolBoxTextPosition meTextPosition; + Link<ToolBox *, void> maClickHdl; + Link<ToolBox *, void> maDoubleClickHdl; + Link<ToolBox *, void> maActivateHdl; + Link<ToolBox *, void> maDeactivateHdl; + Link<ToolBox *, void> maSelectHdl; + Link<ToolBox *, void> maMenuButtonHdl; + Link<StateChangedType const *, void> maStateChangedHandler; + Link<DataChangedEvent const *, void> maDataChangedHandler; + /** StatusListener. Notifies about rotated images etc */ + rtl::Reference<VclStatusListener<ToolBox>> mpStatusListener; + +public: + using Window::ImplInit; +private: + SAL_DLLPRIVATE void InvalidateItem(ImplToolItems::size_type nPosition); + SAL_DLLPRIVATE void InvalidateSpin(bool bInvalidateUpper = true, + bool bInvalidateLower = true); + SAL_DLLPRIVATE void InvalidateMenuButton(); + + SAL_DLLPRIVATE void ImplInitToolBoxData(); + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + using DockingWindow::ImplInitSettings; + SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); + SAL_DLLPRIVATE ImplToolItem* ImplGetItem( sal_uInt16 nId ) const; + SAL_DLLPRIVATE bool ImplCalcItem(); + SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcBreaks( long nWidth, long* pMaxLineWidth, bool bCalcHorz ) const; + SAL_DLLPRIVATE void ImplFormat( bool bResize = false ); + SAL_DLLPRIVATE void ImplDrawSpin(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawSeparator(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, const tools::Rectangle& rRect); + SAL_DLLPRIVATE void ImplDrawItem(vcl::RenderContext& rRenderContext, ImplToolItems::size_type nPos, sal_uInt16 nHighlight ); + using Window::ImplInvalidate; + SAL_DLLPRIVATE void ImplInvalidate( bool bNewCalc = false, bool bFullPaint = false ); + SAL_DLLPRIVATE void ImplUpdateItem( ImplToolItems::size_type nIndex = ITEM_NOTFOUND ); + SAL_DLLPRIVATE bool ImplHandleMouseMove( const MouseEvent& rMEvt, bool bRepeat = false ); + SAL_DLLPRIVATE bool ImplHandleMouseButtonUp( const MouseEvent& rMEvt, bool bCancel = false ); + SAL_DLLPRIVATE void ImplChangeHighlight( ImplToolItem const * pItem, bool bNoGrabFocus = false ); + SAL_DLLPRIVATE bool ImplChangeHighlightUpDn( bool bUp, bool bNoCycle = false ); + SAL_DLLPRIVATE ImplToolItems::size_type ImplGetItemLine( ImplToolItem const * pCurrentItem ); + SAL_DLLPRIVATE ImplToolItem* ImplGetFirstValidItem( ImplToolItems::size_type nLine ); + SAL_DLLPRIVATE bool ImplOpenItem( vcl::KeyCode aKeyCode ); + SAL_DLLPRIVATE bool ImplActivateItem( vcl::KeyCode aKeyCode ); + SAL_DLLPRIVATE void ImplShowFocus(); + SAL_DLLPRIVATE void ImplHideFocus(); + SAL_DLLPRIVATE void ImplUpdateInputEnable(); + SAL_DLLPRIVATE void ImplFillLayoutData(); + SAL_DLLPRIVATE bool ImplHasClippedItems(); + SAL_DLLPRIVATE Point ImplGetPopupPosition( const tools::Rectangle& rRect ) const; + SAL_DLLPRIVATE bool ImplIsFloatingMode() const; + SAL_DLLPRIVATE bool ImplIsInPopupMode() const; + SAL_DLLPRIVATE const OUString& ImplGetHelpText( sal_uInt16 nItemId ) const; + SAL_DLLPRIVATE Size ImplGetOptimalFloatingSize(); + SAL_DLLPRIVATE bool ImplHasExternalMenubutton(); + SAL_DLLPRIVATE void ImplDrawFloatwinBorder(vcl::RenderContext& rRenderContext, ImplToolItem const * pItem ); + + DECL_DLLPRIVATE_LINK( ImplUpdateHdl, Timer*, void ); + DECL_DLLPRIVATE_LINK( ImplCustomMenuListener, VclMenuEvent&, void ); + DECL_DLLPRIVATE_LINK( ImplDropdownLongClickHdl, Timer*, void ); + + ToolBox (const ToolBox &) = delete; + ToolBox& operator= (const ToolBox &) = delete; + +public: + SAL_DLLPRIVATE void ImplFloatControl( bool bStart, FloatingWindow* pWindow ); + SAL_DLLPRIVATE void ImplDisableFlatButtons(); + + SAL_DLLPRIVATE int ImplGetDragWidth() const; + static SAL_DLLPRIVATE int ImplGetDragWidth( const vcl::RenderContext& rRenderContext, + bool bHorz ); + SAL_DLLPRIVATE void ImplUpdateDragArea() const; + SAL_DLLPRIVATE void ImplCalcBorder( WindowAlign eAlign, long& rLeft, long& rTop, + long& rRight, long& rBottom ) const; + SAL_DLLPRIVATE void ImplCheckUpdate(); + static SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext, + const tools::Rectangle &aDragArea, int nDragWidth, + WindowAlign eAlign, bool bHorz); + + SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawGradientBackground(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE bool ImplDrawNativeBackground(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void ImplDrawTransparentBackground(const vcl::Region &rRegion); + SAL_DLLPRIVATE static void ImplDrawConstantBackground(vcl::RenderContext& rRenderContext, const vcl::Region &rRegion, bool bIsInPopupMode); + SAL_DLLPRIVATE void ImplDrawBackground(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect); + + SAL_DLLPRIVATE void ImplErase(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, bool bHighlight, bool bHasOpenPopup = false ); + + SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE const ImplToolItem *ImplGetFirstClippedItem() const; + SAL_DLLPRIVATE Size ImplCalcSize( ImplToolItems::size_type nCalcLines, sal_uInt16 nCalcMode = 0 ); + SAL_DLLPRIVATE void ImplCalcFloatSizes(); + SAL_DLLPRIVATE Size ImplCalcFloatSize( ImplToolItems::size_type& rLines ); + SAL_DLLPRIVATE void ImplCalcMinMaxFloatSize( Size& rMinSize, Size& rMaxSize ); + SAL_DLLPRIVATE void ImplSetMinMaxFloatSize(); + SAL_DLLPRIVATE ImplToolItems::size_type ImplCalcLines( long nToolSize ) const; + SAL_DLLPRIVATE sal_uInt16 ImplTestLineSize( const Point& rPos ) const; + SAL_DLLPRIVATE void ImplLineSizing( const Point& rPos, tools::Rectangle& rRect, sal_uInt16 nLineMode ); + SAL_DLLPRIVATE static ImplToolItems::size_type ImplFindItemPos( const ImplToolItem* pItem, const ImplToolItems& rList ); + SAL_DLLPRIVATE void ImplDrawMenuButton(vcl::RenderContext& rRenderContext, bool bHighlight); + SAL_DLLPRIVATE void ImplDrawButton(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, sal_uInt16 highlight, bool bChecked, bool bEnabled, bool bIsWindow); + SAL_DLLPRIVATE ImplToolItems::size_type ImplCountLineBreaks() const; + SAL_DLLPRIVATE ImplToolBoxPrivateData* ImplGetToolBoxPrivateData() const { return mpData.get(); } + + SAL_DLLPRIVATE void ApplyBackgroundSettings(vcl::RenderContext&, const StyleSettings&); + SAL_DLLPRIVATE void ApplyForegroundSettings(vcl::RenderContext&, const StyleSettings&); + +protected: + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + +public: + ToolBox(vcl::Window* pParent, WinBits nStyle = 0); + ToolBox(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription, + const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>()); + virtual ~ToolBox() override; + virtual void dispose() override; + + virtual void Click(); + void DoubleClick(); + virtual void Activate() override; + virtual void Deactivate() override; + void Highlight(); + virtual void Select(); + + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void Tracking( const TrackingEvent& rTEvt ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void LoseFocus() override; + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + virtual void ToggleFloatingMode() override; + virtual void StartDocking() override; + virtual bool Docking( const Point& rPos, tools::Rectangle& rRect ) override; + virtual void EndDocking( const tools::Rectangle& rRect, bool bFloatMode ) override; + virtual void Resizing( Size& rSize ) override; + virtual Size GetOptimalSize() const override; + virtual void doDeferredInit(WinBits nBits) override; + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + + /// Insert a command (like '.uno:Save'). + virtual void InsertItem( const OUString& rCommand, + const css::uno::Reference<css::frame::XFrame>& rFrame, + ToolBoxItemBits nBits, + const Size& rRequestedSize, + ImplToolItems::size_type nPos = APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + ToolBoxItemBits nBits = ToolBoxItemBits::NONE, + ImplToolItems::size_type nPos = APPEND ); + void InsertItem( sal_uInt16 nItemId, const Image& rImage, + const OUString& rText, + ToolBoxItemBits nBits = ToolBoxItemBits::NONE, + ImplToolItems::size_type nPos = APPEND ); + void InsertItem( sal_uInt16 nItemId, const OUString& rText, + ToolBoxItemBits nBits = ToolBoxItemBits::NONE, + ImplToolItems::size_type nPos = APPEND ); + void InsertWindow( sal_uInt16 nItemId, vcl::Window* pWindow, + ToolBoxItemBits nBits = ToolBoxItemBits::NONE, + ImplToolItems::size_type nPos = APPEND ); + void InsertSpace(); + void InsertSeparator( ImplToolItems::size_type nPos = APPEND, sal_uInt16 nPixSize = 0 ); + void InsertBreak( ImplToolItems::size_type nPos = APPEND ); + void RemoveItem( ImplToolItems::size_type nPos ); + void CopyItem( const ToolBox& rToolBox, sal_uInt16 nItemId ); + void Clear(); + + void SetButtonType( ButtonType eNewType ); + ButtonType GetButtonType() const { return meButtonType; } + + // sets a fixed button size (small, large or dontcare (==autosize)) + void SetToolboxButtonSize( ToolBoxButtonSize eSize ); + ToolBoxButtonSize GetToolboxButtonSize() const; + vcl::ImageType GetImageSize() const; + + void SetAlign( WindowAlign eNewAlign = WindowAlign::Top ); + WindowAlign GetAlign() const { return meAlign; } + bool IsHorizontal() const { return mbHorz; } + + void SetLineCount( ImplToolItems::size_type nNewLines ); + void ShowLine( bool bNext ); + + ImplToolItems::size_type GetItemCount() const; + ToolBoxItemType GetItemType( ImplToolItems::size_type nPos ) const; + ImplToolItems::size_type GetItemPos( sal_uInt16 nItemId ) const; + ImplToolItems::size_type GetItemPos( const Point& rPos ) const; + sal_uInt16 GetItemId( ImplToolItems::size_type nPos ) const; + sal_uInt16 GetItemId( const Point& rPos ) const; + /// Map the command name (like .uno:Save) back to item id. + sal_uInt16 GetItemId( const OUString& rCommand ) const; + tools::Rectangle GetItemRect( sal_uInt16 nItemId ); + tools::Rectangle GetItemPosRect( ImplToolItems::size_type nPos ); + tools::Rectangle const & GetOverflowRect() const; + + /// Returns size of the bitmap / text that is inside this toolbox item. + Size GetItemContentSize( sal_uInt16 nItemId ); + + sal_uInt16 GetCurItemId() const { return mnCurItemId; } + sal_uInt16 GetDownItemId() const { return mnDownItemId; } + sal_uInt16 GetModifier() const { return mnMouseModifier; } + + void SetItemBits( sal_uInt16 nItemId, ToolBoxItemBits nBits ); + ToolBoxItemBits GetItemBits( sal_uInt16 nItemId ) const; + + void SetItemExpand( sal_uInt16 nItemId, bool bExpand ); + // e.g. a label used as an itemwindow + void SetItemWindowNonInteractive(sal_uInt16 nItemId, bool bNonInteractive); + + + void SetItemData( sal_uInt16 nItemId, void* pNewData ); + void* GetItemData( sal_uInt16 nItemId ) const; + void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); + Image GetItemImage( sal_uInt16 nItemId ) const; + void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 ); + void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ); + void SetItemText( sal_uInt16 nItemId, const OUString& rText ); + const OUString& GetItemText( sal_uInt16 nItemId ) const; + void SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow ); + vcl::Window* GetItemWindow( sal_uInt16 nItemId ) const; + sal_uInt16 GetHighlightItemId() const { return mnHighItemId; } + + void EndSelection(); + + void SetItemDown( sal_uInt16 nItemId, bool bDown ); + + void SetItemState( sal_uInt16 nItemId, TriState eState ); + TriState GetItemState( sal_uInt16 nItemId ) const; + + void CheckItem( sal_uInt16 nItemId, bool bCheck = true ); + bool IsItemChecked( sal_uInt16 nItemId ) const; + + void EnableItem( sal_uInt16 nItemId, bool bEnable = true ); + bool IsItemEnabled( sal_uInt16 nItemId ) const; + + void TriggerItem( sal_uInt16 nItemId ); + + /// Shows or hides items. + void ShowItem(sal_uInt16 nItemId, bool bVisible = true); + + /// Convenience method to hide items (via ShowItem). + void HideItem(sal_uInt16 nItemId) { ShowItem( nItemId, false ); } + + bool IsItemClipped( sal_uInt16 nItemId ) const; + bool IsItemVisible( sal_uInt16 nItemId ) const; + bool IsItemReallyVisible( sal_uInt16 nItemId ) const; + + void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); + OUString GetItemCommand( sal_uInt16 nItemId ) const; + + using Window::SetQuickHelpText; + void SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText ); + using Window::GetQuickHelpText; + OUString GetQuickHelpText( sal_uInt16 nItemId ) const; + + void SetHelpText( sal_uInt16 nItemId, const OUString& rText ); + const OUString& GetHelpText( sal_uInt16 nItemId ) const; + + void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); + + // window size according to current alignment, floating state and number of lines + Size CalcWindowSizePixel(); + // window size according to current alignment, floating state and a given number of lines + Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines ); + // window size according to current floating state and a given number of lines and a given alignment + Size CalcWindowSizePixel( ImplToolItems::size_type nCalcLines, WindowAlign eAlign ); + // floating window size according to number of lines (uses the number of line breaks) + Size CalcFloatingWindowSizePixel(); + // floating window size with a given number of lines + Size CalcFloatingWindowSizePixel( ImplToolItems::size_type nCalcLines ); + // automatic window size for popup mode + Size CalcPopupWindowSizePixel(); + + // computes the smallest useful size when docked, ie with the first item visible only (+drag area and menu button) + Size CalcMinimumWindowSizePixel(); + + ImplToolItems::size_type GetFloatingLines() const; + + void SetStyle( WinBits nNewStyle ); + WinBits GetStyle() const { return mnWinStyle; } + + // enable/disable undocking + void Lock( bool bLock ); + // read configuration to determine locking behaviour + static bool AlwaysLocked(); + + void SetOutStyle( sal_uInt16 nNewStyle ); + sal_uInt16 GetOutStyle() const { return mnOutStyle; } + + void EnableCustomize( bool bEnable = true ); + bool IsCustomize() const { return mbCustomize; } + + using DockingWindow::SetHelpText; + using DockingWindow::GetHelpText; + using DockingWindow::SetHelpId; + using DockingWindow::GetHelpId; + + void SetClickHdl( const Link<ToolBox *, void>& rLink ) { maClickHdl = rLink; } + void SetDoubleClickHdl( const Link<ToolBox *, void>& rLink ) { maDoubleClickHdl = rLink; } + void SetDropdownClickHdl( const Link<ToolBox *, void>& rLink ); + void SetActivateHdl( const Link<ToolBox *, void>& rLink ) { maActivateHdl = rLink; } + void SetDeactivateHdl( const Link<ToolBox *, void>& rLink ) { maDeactivateHdl = rLink; } + void SetSelectHdl( const Link<ToolBox *, void>& rLink ) { maSelectHdl = rLink; } + void SetStateChangedHdl( const Link<StateChangedType const *, void>& aLink ) { maStateChangedHandler = aLink; } + void SetDataChangedHdl( const Link<DataChangedEvent const *, void>& aLink ) { maDataChangedHandler = aLink; } + void SetMenuButtonHdl( const Link<ToolBox *, void>& rLink ) { maMenuButtonHdl = rLink; } + + // support for custom menu (eg for configuration) + // note: this menu will also be used to display currently + // clipped toolbox items, so you should only touch + // items that you added by yourself + // the private toolbox items will only use item ids starting from TOOLBOX_MENUITEM_START + // to allow for customization of the menu the corresponding handler is called + // when the menu button was clicked and before the menu is executed + void SetMenuType( ToolBoxMenuType aType = ToolBoxMenuType::Customize ); + ToolBoxMenuType GetMenuType() const; + bool IsMenuEnabled() const; + PopupMenu* GetMenu() const; + void UpdateCustomMenu(); + void SetMenuExecuteHdl( const Link<ToolBox *, void>& rLink ); + + // open custommenu + void ExecuteCustomMenu( const tools::Rectangle& rRect = tools::Rectangle() ); + + // allow Click Handler to distinguish between mouse and key input + bool IsKeyEvent() const { return mbIsKeyEvent; } + + // allows framework to set/query the planned popupmode + bool WillUsePopupMode() const; + void WillUsePopupMode( bool b); + + // accessibility helpers + + // gets the displayed text + OUString GetDisplayText() const override; + // returns the bounding box for the character at index nIndex + // where nIndex is relative to the starting index of the item + // with id nItemId (in coordinates of the displaying window) + tools::Rectangle GetCharacterBounds( sal_uInt16 nItemId, long nIndex ); + // -1 is returned if no character is at that point + // if an index is found the corresponding item id is filled in (else 0) + long GetIndexForPoint( const Point& rPoint, sal_uInt16& rItemID ); + + static Size GetDefaultImageSize(ToolBoxButtonSize eToolBoxButtonSize); + Size GetDefaultImageSize() const; + void ChangeHighlight( ImplToolItems::size_type nPos ); + + + void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout ); + void statusChanged(const css::frame::FeatureStateEvent& rEvent); + + void SetToolBoxTextPosition( ToolBoxTextPosition ePosition ); + + void SetLineSpacing(bool b) { mbLineSpacing = b; } + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; +}; + +inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck ) +{ + SetItemState( nItemId, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE ); +} + +inline bool ToolBox::IsItemChecked( sal_uInt16 nItemId ) const +{ + return (GetItemState( nItemId ) == TRISTATE_TRUE); +} + +inline Size ToolBox::CalcWindowSizePixel() +{ + return CalcWindowSizePixel( mnLines ); +} + +inline ToolBox::ImplToolItems::size_type ToolBox::GetFloatingLines() const +{ + return mnFloatLines; +} + +#endif // INCLUDED_VCL_TOOLBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/README b/include/vcl/toolkit/README new file mode 100644 index 000000000..889f0b20a --- /dev/null +++ b/include/vcl/toolkit/README @@ -0,0 +1,2 @@ +These are includes which are now only used by the toolkit module, which exposes +them via uno. Don't use these in any new code. diff --git a/include/vcl/toolkit/button.hxx b/include/vcl/toolkit/button.hxx new file mode 100644 index 000000000..6f8910e43 --- /dev/null +++ b/include/vcl/toolkit/button.hxx @@ -0,0 +1,51 @@ +/* -*- 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 . + */ +#pragma once + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <vcl/button.hxx> + +class CloseButton final : public CancelButton +{ +public: + explicit CloseButton(vcl::Window* pParent, WinBits nStyle = 0); +}; + +class VCL_DLLPUBLIC HelpButton : public PushButton +{ +protected: + using PushButton::ImplInit; +private: + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + + HelpButton( const HelpButton & ) = delete; + HelpButton & operator= ( const HelpButton & ) = delete; + + virtual void StateChanged( StateChangedType nStateChange ) override; + +public: + explicit HelpButton( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual void Click() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/combobox.hxx b/include/vcl/toolkit/combobox.hxx new file mode 100644 index 000000000..611bce590 --- /dev/null +++ b/include/vcl/toolkit/combobox.hxx @@ -0,0 +1,194 @@ +/* -*- 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_COMBOBOX_HXX +#define INCLUDED_VCL_COMBOBOX_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/edit.hxx> + +#define COMBOBOX_APPEND (SAL_MAX_INT32) +#define COMBOBOX_ENTRY_NOTFOUND (SAL_MAX_INT32) +#define COMBOBOX_MAX_ENTRIES (SAL_MAX_INT32 - 1) + +class UserDrawEvent; + +/// A widget used to choose from a list of items and which has an entry. +class VCL_DLLPUBLIC ComboBox : public Edit +{ +private: + struct SAL_DLLPRIVATE Impl; + std::unique_ptr<Impl> m_pImpl; + +protected: + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplCalcEditHeight(); + SAL_DLLPRIVATE long getMaxWidthScrollBarAndDownButton() const; + +protected: + bool IsDropDownBox() const; + + virtual void FillLayoutData() const override; + +public: + explicit ComboBox( vcl::Window* pParent, WinBits nStyle = 0 ); + virtual ~ComboBox() override; + virtual void dispose() override; + + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + void Select(); + void DoubleClick(); + + virtual void Modify() override; + + virtual const Wallpaper& GetDisplayBackground() const override; + + virtual void setPosSizePixel( long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags = PosSizeFlags::All ) override; + + tools::Rectangle GetDropDownPosSizePixel() const; + + void AdaptDropDownLineCountToMaximum(); + void SetDropDownLineCount( sal_uInt16 nLines ); + sal_uInt16 GetDropDownLineCount() const; + + void EnableAutoSize( bool bAuto ); + bool IsAutoSizeEnabled() const; + + virtual void SetText( const OUString& rStr ) override; + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override; + + sal_Int32 InsertEntry(const OUString& rStr, sal_Int32 nPos = COMBOBOX_APPEND); + sal_Int32 InsertEntryWithImage( const OUString& rStr, const Image& rImage, sal_Int32 nPos = COMBOBOX_APPEND ); + + void RemoveEntryAt(sal_Int32 nPos); + + void Clear(); + sal_Int32 GetEntryPos( const OUString& rStr ) const; + Image GetEntryImage( sal_Int32 nPos ) const; + OUString GetEntry( sal_Int32 nPos ) const; + sal_Int32 GetEntryCount() const; + + bool IsTravelSelect() const; + bool IsInDropDown() const; + void ToggleDropDown(); + + void SetUserItemSize( const Size& rSz ); + void EnableUserDraw( bool bUserDraw ); + bool IsUserDrawEnabled() const; + + void DrawEntry( const UserDrawEvent& rEvt ); + void SetBorderStyle( WindowBorderStyle nBorderStyle ); + + /** + * Adds a new separator at the given position n. + */ + void AddSeparator( sal_Int32 n ); + + void EnableAutocomplete( bool bEnable, bool bMatchCase = false ); + bool IsAutocompleteEnabled() const; + + bool IsMultiSelectionEnabled() const; + + void SetSelectHdl(const Link<ComboBox&,void>& rLink); + void SetEntryActivateHdl(const Link<Edit&,bool>& rLink); + void SetUserDrawHdl(const Link<UserDrawEvent*, void>& rLink); + + Size CalcMinimumSize() const override; + virtual Size GetOptimalSize() const override; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void SetMRUEntries( const OUString& rEntries ); + OUString GetMRUEntries() const; + void SetMaxMRUCount( sal_Int32 n ); + sal_Int32 GetMaxMRUCount() const; + void SetEntryData( sal_Int32 nPos, void* pNewData ); + void* GetEntryData( sal_Int32 nPos ) const; + + sal_Int32 GetTopEntry() const; + + sal_uInt16 GetDisplayLineCount() const; + + sal_Int32 GetSelectedEntryCount() const; + sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex = 0 ) const; + bool IsEntryPosSelected( sal_Int32 nPos ) const; + void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ); + void SetNoSelection(); + tools::Rectangle GetBoundingRectangle( sal_Int32 nItem ) const; + + // determine if Select was called due to typing or cursoring in the + // combobox, as opposed to something selected from the menu or via some + // other route. e.g. the toolbar fontsize combobox wants to immediately + // change size only if something is picked from the combobox menu, other + // changes don't auto-apply until the user presses return + bool IsModifyByKeyboard() const; + + // determine if Edit::Modify was called due to the ComboBox changing the edit area + // itself + bool IsSyntheticModify() const; + + + /** checks whether a certain point lies within the bounds of + a list item and returns the item as well as the character position + the point is at. + + <p>If the point is inside an item the item pos is put into <code>rPos</code> and + the item-relative character index is returned. If the point is not inside + an item -1 is returned and rPos is unchanged.</p> + + @param rPoint + tells the point for which an item is requested. + + @param rPos + gets the item at the specified point <code>rPoint</code> + + @returns + the item-relative character index at point <code>rPos</code> or -1 + if no item is at that point. + */ + using Control::GetIndexForPoint; + long GetIndexForPoint( const Point& rPoint, sal_Int32 & rPos ) const; + + void setMaxWidthChars(sal_Int32 nWidth); + + void SetWidthInChars(sal_Int32 nWidthInChars); + + long GetDropDownEntryHeight() const; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + virtual FactoryFunction GetUITestFactory() const override; +}; + +#endif // _COMBOBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/controllayout.hxx b/include/vcl/toolkit/controllayout.hxx new file mode 100644 index 000000000..ffd643f64 --- /dev/null +++ b/include/vcl/toolkit/controllayout.hxx @@ -0,0 +1,81 @@ +/* -*- 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_CONTROLLAYOUT_HXX +#define INCLUDED_VCL_CONTROLLAYOUT_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <vector> +#include <vcl/ctrl.hxx> +#include <vcl/dllapi.h> + +namespace vcl +{ + +struct VCL_DLLPUBLIC ControlLayoutData +{ + // contains the string really displayed + // there must be exactly one bounding rectangle in m_aUnicodeBoundRects + // for every character in m_aDisplayText + OUString m_aDisplayText; + // the bounding rectangle of every character + // where one character may consist of many glyphs + std::vector< tools::Rectangle > m_aUnicodeBoundRects; + // start indices of lines + std::vector< long > m_aLineIndices; + // notify parent control on destruction + VclPtr<const Control> m_pParent; + + ControlLayoutData(); + ~ControlLayoutData(); + + tools::Rectangle GetCharacterBounds( long nIndex ) const; + // returns the character index for corresponding to rPoint (in control coordinates) + // -1 is returned if no character is at that point + long GetIndexForPoint( const Point& rPoint ) const; + // returns the number of lines in the result of GetDisplayText() + long GetLineCount() const; + // returns the interval [start,end] of line nLine + // returns [-1,-1] for an invalid line + ::Pair GetLineStartEnd( long nLine ) const; + /** ToRelativeLineIndex changes a layout data index to a count relative to its line. + + This is equivalent to getting the line start/end pairs with + GetLineStartEnd until the index lies within [start,end] of a line + + @param nIndex + the absolute index inside the display text to be changed to a relative index + + @returns + the relative index inside the displayed line or -1 if the absolute index does + not match any line + */ + long ToRelativeLineIndex( long nIndex ) const; +}; + +} // namespace vcl + +#endif // INCLUDED_VCL_CONTROLLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/dialog.hxx b/include/vcl/toolkit/dialog.hxx new file mode 100644 index 000000000..c663f21a2 --- /dev/null +++ b/include/vcl/toolkit/dialog.hxx @@ -0,0 +1,161 @@ +/* -*- 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_DIALOG_HXX +#define INCLUDED_VCL_DIALOG_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/abstdlg.hxx> + +struct DialogImpl; +class PushButton; +class VclBox; +class VclButtonBox; + +class VCL_DLLPUBLIC Dialog : public SystemWindow +{ +public: + enum class InitFlag + { + /** Use given parent or get a default one using GetDefaultParent(...) */ + Default, + + /** No Parent */ + NoParent + }; + +private: + std::unique_ptr<DialogImpl> mpDialogImpl; + long mnMousePositioned; + bool mbInExecute; + bool mbInSyncExecute; + bool mbInClose; + bool mbModalMode; + InitFlag mnInitFlag; // used for deferred init + + VclPtr<VclButtonBox> mpActionArea; + VclPtr<VclBox> mpContentArea; + + SAL_DLLPRIVATE void RemoveFromDlgList(); + SAL_DLLPRIVATE void ImplInitDialogData(); + SAL_DLLPRIVATE void ImplInitSettings(); + SAL_DLLPRIVATE VclPtr<vcl::Window> AddBorderWindow(vcl::Window* pParent, WinBits nBits); + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; + + SAL_DLLPRIVATE Dialog (const Dialog &) = delete; + SAL_DLLPRIVATE Dialog & operator= (const Dialog &) = delete; + + DECL_DLLPRIVATE_LINK(ImplAsyncCloseHdl, void*, void); + DECL_DLLPRIVATE_LINK(ResponseHdl, Button*, void); + +protected: + void ImplInitDialog( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default ); + + /// Find and set the LOK notifier according to the pParent. + void ImplLOKNotifier(vcl::Window* pParent); + +public: + SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; } + virtual void doDeferredInit(WinBits nBits) override; + SAL_DLLPRIVATE void disposeOwnedButtons(); + +protected: + explicit Dialog( WindowType nType ); + explicit Dialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription); + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void settingOptimalLayoutSize(Window *pBox) override; + +protected: + friend class VclBuilder; + friend class SalInstanceBuilder; + void set_action_area(VclButtonBox* pBox); + virtual void set_content_area(VclBox* pBox); + +public: + explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG, InitFlag eFlag = InitFlag::Default ); + virtual ~Dialog() override; + virtual void dispose() override; + + // get the default parent for a dialog as is done in standard initialization + static vcl::Window* GetDefaultParent(WinBits nStyle); + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void Command( const CommandEvent& rCEvt ) override; + + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override; + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + VclButtonBox* get_action_area() { return mpActionArea; } + VclBox* get_content_area() { return mpContentArea; } + + virtual bool Close() override; + + short Execute(); + bool IsInExecute() const { return mbInExecute; } + // Return true when dialog is synchronously executed (calling ::Execute()) + bool IsInSyncExecute() const { return mbInSyncExecute; }; + + virtual FactoryFunction GetUITestFactory() const override; + +private: + bool ImplStartExecute(); + static void ImplEndExecuteModal(); + void ImplSetModalInputMode(bool bModal); +public: + + /// Commence execution of a modal dialog, disposes owner on failure + bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx); + + // Dialog::Execute replacement API + + + void EndDialog( long nResult = RET_CANCEL ); + + void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + + void SetModalInputMode( bool bModal ); + bool IsModalInputMode() const { return mbModalMode; } + + void GrabFocusToFirstControl(); + virtual void Resize() override; + + void Activate() override; + + void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink); + void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink); + + void add_button(PushButton* pButton, int nResponse, bool bTransferOwnership); + void set_default_response(int nResponse); + int get_default_response() const; + vcl::Window* get_widget_for_response(int nResponse); +}; + +#endif // INCLUDED_VCL_DIALOG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx new file mode 100644 index 000000000..e78b174e7 --- /dev/null +++ b/include/vcl/toolkit/field.hxx @@ -0,0 +1,255 @@ +/* -*- 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_TOOLKIT_FIELD_HXX +#define INCLUDED_VCL_TOOLKIT_FIELD_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/toolkit/combobox.hxx> +#include <vcl/field.hxx> +#include <vcl/longcurr.hxx> + +class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter +{ +public: + virtual ~MetricFormatter() override; + + virtual void Reformat() override; + + virtual void SetUnit( FieldUnit meUnit ); + FieldUnit GetUnit() const { return meUnit; } + void SetCustomUnitText( const OUString& rStr ); + const OUString& GetCustomUnitText() const { return maCustomUnitText; } + + using NumericFormatter::SetMax; + void SetMax( sal_Int64 nNewMax, FieldUnit eInUnit ); + using NumericFormatter::GetMax; + sal_Int64 GetMax( FieldUnit eOutUnit ) const; + using NumericFormatter::SetMin; + void SetMin( sal_Int64 nNewMin, FieldUnit eInUnit ); + using NumericFormatter::GetMin; + sal_Int64 GetMin( FieldUnit eOutUnit ) const; + + void SetValue( sal_Int64 nNewValue, FieldUnit eInUnit ); + virtual void SetValue( sal_Int64 nValue ) override; + using NumericFormatter::SetUserValue; + void SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit ); + using NumericFormatter::GetValue; + sal_Int64 GetValue( FieldUnit eOutUnit ) const; + virtual OUString CreateFieldText( sal_Int64 nValue ) const override; + sal_Int64 GetCorrectedValue( FieldUnit eOutUnit ) const; + +protected: + FieldUnit meUnit; + + MetricFormatter(Edit* pEdit); + + SAL_DLLPRIVATE void ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr ); + + virtual sal_Int64 GetValueFromString(const OUString& rStr) const override; + sal_Int64 GetValueFromStringUnit(const OUString& rStr, FieldUnit eOutUnit) const; + +private: + OUString maCustomUnitText; +}; + +class VCL_DLLPUBLIC MetricField : public SpinField, public MetricFormatter +{ +public: + explicit MetricField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual Size CalcMinimumSize() const override; + + virtual void Modify() override; + + virtual void Up() override; + virtual void Down() override; + virtual void First() override; + virtual void Last() override; + + virtual void SetUnit( FieldUnit meUnit ) override; + + void SetFirst( sal_Int64 nNewFirst, FieldUnit eInUnit ); + sal_Int64 GetFirst( FieldUnit eOutUnit ) const; + void SetLast( sal_Int64 nNewLast, FieldUnit eInUnit ); + sal_Int64 GetLast( FieldUnit eOutUnit ) const; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + virtual void dispose() override; + + virtual boost::property_tree::ptree DumpAsPropertyTree() override; + virtual FactoryFunction GetUITestFactory() const override; +}; + +class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter +{ +public: + explicit MetricBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual Size CalcMinimumSize() const override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + + // Needed, because GetValue() with nPos hide these functions + using MetricFormatter::GetValue; + + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) CurrencyFormatter : public NumericFormatter +{ +protected: + CurrencyFormatter(Edit* pEdit); + SAL_DLLPRIVATE void ImplCurrencyReformat( const OUString& rStr, OUString& rOutStr ); + virtual sal_Int64 GetValueFromString(const OUString& rStr) const override; + +public: + virtual ~CurrencyFormatter() override; + + virtual void Reformat() override; + + virtual void SetValue( sal_Int64 nNewValue ) override; + virtual OUString CreateFieldText( sal_Int64 nValue ) const override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) CurrencyField final : public SpinField, public CurrencyFormatter +{ +public: + CurrencyField( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void Up() override; + virtual void Down() override; + virtual void First() override; + virtual void Last() override; + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) NumericBox : public ComboBox, public NumericFormatter +{ + SAL_DLLPRIVATE void ImplNumericReformat( const OUString& rStr, sal_Int64& rValue, OUString& rOutStr ); +public: + explicit NumericBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual Size CalcMinimumSize() const override; + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) PatternBox final : public ComboBox, public PatternFormatter +{ +public: + PatternBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) CurrencyBox final : public ComboBox, public CurrencyFormatter +{ +public: + explicit CurrencyBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) DateBox final : public ComboBox, public DateFormatter +{ +public: + explicit DateBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TimeBox final : public ComboBox, public TimeFormatter +{ +public: + explicit TimeBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + + virtual void Modify() override; + + virtual void ReformatAll() override; + virtual void dispose() override; +}; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) LongCurrencyBox final : public ComboBox, public LongCurrencyFormatter +{ +public: + LongCurrencyBox( vcl::Window* pParent, WinBits nWinStyle ); + + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + + void Modify() override; + void ReformatAll() override; +}; + +#endif // INCLUDED_VCL_FIELD_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/fixedhyper.hxx b/include/vcl/toolkit/fixedhyper.hxx new file mode 100644 index 000000000..cb4e6bae2 --- /dev/null +++ b/include/vcl/toolkit/fixedhyper.hxx @@ -0,0 +1,121 @@ +/* -*- 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_FIXEDHYPER_HXX +#define INCLUDED_VCL_FIXEDHYPER_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/fixed.hxx> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) FixedHyperlink final : public FixedText +{ +private: + long m_nTextLen; + PointerStyle m_aOldPointer; + Link<FixedHyperlink&,void> m_aClickHdl; + OUString m_sURL; + + /** initializes the font (link color and underline). + + Called by the Ctors. + */ + void Initialize(); + + /** is position X position hitting text */ + SAL_DLLPRIVATE bool ImplIsOverText(Point rPosition); + + DECL_LINK(HandleClick, FixedHyperlink&, void); + + /** overwrites Window::MouseMove(). + + Changes the pointer only over the text. + */ + virtual void MouseMove( const MouseEvent& rMEvt ) override; + + /** overwrites Window::MouseButtonUp(). + + Calls the set link if the mouse is over the text. + */ + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + + /** overwrites Window::RequestHelp(). + + Shows tooltip only if the mouse is over the text. + */ + virtual void RequestHelp( const HelpEvent& rHEvt ) override; + +public: + /** ctors + + With WinBits. + */ + FixedHyperlink( vcl::Window* pParent, WinBits nWinStyle = 0 ); + + /** overwrites Window::GetFocus(). + + Changes the color of the text and shows a focus rectangle. + */ + virtual void GetFocus() override; + + /** overwrites Window::LoseFocus(). + + Changes the color of the text and hides the focus rectangle. + */ + virtual void LoseFocus() override; + + /** overwrites Window::KeyInput(). + + KEY_RETURN and KEY_SPACE calls the link handler. + */ + virtual void KeyInput( const KeyEvent& rKEvt ) override; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; + + + /** sets m_aClickHdl with rLink. + + m_aClickHdl is called if the text is clicked. + */ + void SetClickHdl( const Link<FixedHyperlink&,void>& rLink ) { m_aClickHdl = rLink; } + const Link<FixedHyperlink&,void>& GetClickHdl() const { return m_aClickHdl; } + + // ::FixedHyperbaseLink + + /** sets the URL of the hyperlink and uses it as tooltip. */ + void SetURL(const OUString& rNewURL); + + /** returns the URL of the hyperlink. + + @return + m_sURL + */ + const OUString& GetURL() const { return m_sURL;} + + /** sets new text and recalculates the text length. */ + virtual void SetText(const OUString& rNewDescription) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/group.hxx b/include/vcl/toolkit/group.hxx new file mode 100644 index 000000000..2bbd344df --- /dev/null +++ b/include/vcl/toolkit/group.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_GROUP_HXX +#define INCLUDED_VCL_GROUP_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) GroupBox : public Control +{ +private: + using Control::ImplInitSettings; + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle ); + SAL_DLLPRIVATE void ImplInitSettings( bool bBackground ); + SAL_DLLPRIVATE void ImplDraw( OutputDevice* pDev, DrawFlags nDrawFlags, + const Point& rPos, const Size& rSize, bool bLayout = false ); + + virtual void FillLayoutData() const override; + virtual const vcl::Font& + GetCanonicalFont( const StyleSettings& _rStyle ) const override; + virtual const Color& + GetCanonicalTextColor( const StyleSettings& _rStyle ) const override; + +public: + explicit GroupBox( vcl::Window* pParent, WinBits nStyle ); + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nType ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; +}; + +#endif // INCLUDED_VCL_GROUP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/imgctrl.hxx b/include/vcl/toolkit/imgctrl.hxx new file mode 100644 index 000000000..00ac76fae --- /dev/null +++ b/include/vcl/toolkit/imgctrl.hxx @@ -0,0 +1,55 @@ +/* -*- 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_IMGCTRL_HXX +#define INCLUDED_VCL_IMGCTRL_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/fixed.hxx> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ImageControl : public FixedImage +{ +private: + ::sal_Int16 mnScaleMode; + +public: + ImageControl( vcl::Window* pParent, WinBits nStyle ); + + // set/get the scale mode. This is one of the css.awt.ImageScaleMode constants + void SetScaleMode( const ::sal_Int16 _nMode ); + ::sal_Int16 GetScaleMode() const { return mnScaleMode; } + + virtual void Resize() override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + +protected: + void ImplDraw( OutputDevice& rDev, const Point& rPos, const Size& rSize ) const; +}; + +#endif // INCLUDED_VCL_IMGCTRL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/morebtn.hxx b/include/vcl/toolkit/morebtn.hxx new file mode 100644 index 000000000..b0648f443 --- /dev/null +++ b/include/vcl/toolkit/morebtn.hxx @@ -0,0 +1,59 @@ +/* -*- 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_MOREBTN_HXX +#define INCLUDED_VCL_MOREBTN_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/button.hxx> +#include <memory> + +struct ImplMoreButtonData; + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MoreButton final : public PushButton +{ + std::unique_ptr<ImplMoreButtonData> mpMBData; + bool mbState; + + MoreButton( const MoreButton & ) = delete; + MoreButton& operator=( const MoreButton & ) = delete; + SAL_DLLPRIVATE void ShowState(); + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + +public: + explicit MoreButton( vcl::Window* pParent, WinBits nStyle ); + virtual ~MoreButton() override; + virtual void dispose() override; + + void Click() override; + + using PushButton::SetState; +}; + +#endif // INCLUDED_VCL_MOREBTN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/prgsbar.hxx b/include/vcl/toolkit/prgsbar.hxx new file mode 100644 index 000000000..7f248b19a --- /dev/null +++ b/include/vcl/toolkit/prgsbar.hxx @@ -0,0 +1,83 @@ +/* -*- 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_PRGSBAR_HXX +#define INCLUDED_VCL_PRGSBAR_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +/************************************************************************* + * + * class ProgressBar + * + * this class is used to display the ProgressBar + * + * ----------------------------------------------------------------------- + * + * WinBits + * + * WB_BORDER border around the window + * WB_3DLOOK 3D representation + * + * ----------------------------------------------------------------------- + * + * Methods + * + * Use SetValue() to set a percentage between 0 and 100. A value larger + * than 100 will cause the last rectangle to start flashing + * + ************************************************************************/ + + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ProgressBar final : public vcl::Window +{ +private: + Point maPos; + long mnPrgsWidth; + long mnPrgsHeight; + sal_uInt16 mnPercent; + sal_uInt16 mnPercentCount; + bool mbCalcNew; + + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit(); + SAL_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground ); + SAL_DLLPRIVATE void ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc); + +public: + ProgressBar( vcl::Window* pParent, WinBits nWinBits ); + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Resize() override; + virtual void StateChanged( StateChangedType nStateChange ) override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual Size GetOptimalSize() const override; + + void SetValue( sal_uInt16 nNewPercent ); +}; + +#endif // INCLUDED_VCL_PRGSBAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/roadmap.hxx b/include/vcl/toolkit/roadmap.hxx new file mode 100644 index 000000000..c2654c1fd --- /dev/null +++ b/include/vcl/toolkit/roadmap.hxx @@ -0,0 +1,118 @@ +/* -*- 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_INC_ROADMAP_HXX +#define INCLUDED_VCL_INC_ROADMAP_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/toolkit/imgctrl.hxx> +#include <memory> + +class Bitmap; + +namespace vcl +{ + +struct RoadmapTypes +{ +public: + typedef sal_Int16 ItemId; + typedef sal_Int32 ItemIndex; +}; + +class HyperLabel; +class RoadmapImpl; +class RoadmapItem; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ORoadmap final : public Control, public RoadmapTypes +{ +public: + ORoadmap( vcl::Window* _pParent, WinBits _nWinStyle ); + virtual ~ORoadmap( ) override; + virtual void dispose() override; + + void SetRoadmapBitmap( const BitmapEx& maBitmap ); + + void EnableRoadmapItem( ItemId _nItemId, bool _bEnable ); + + void ChangeRoadmapItemLabel( ItemId _nID, const OUString& sLabel ); + void ChangeRoadmapItemID( ItemId _nID, ItemId NewID ); + + void SetRoadmapInteractive( bool _bInteractive ); + bool IsRoadmapInteractive() const; + + void SetRoadmapComplete( bool _bComplete ); + bool IsRoadmapComplete() const; + + ItemIndex GetItemCount() const; + ItemId GetItemID( ItemIndex _nIndex ) const; + + void InsertRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled ); + void ReplaceRoadmapItem( ItemIndex Index, const OUString& RoadmapItem, ItemId _nUniqueId, bool _bEnabled ); + void DeleteRoadmapItem( ItemIndex _nIndex ); + + ItemId GetCurrentRoadmapItemID() const; + bool SelectRoadmapItemByID( ItemId _nItemID ); + + void SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl ); + Link<LinkParamNone*,void> const & GetItemSelectHdl( ) const; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual void GetFocus() override; + virtual void ApplySettings( vcl::RenderContext& rRenderContext ) override; + +private: + bool PreNotify( NotifyEvent& rNEvt ) override; + + /// called when an item has been selected by any means + void Select(); + + DECL_LINK(ImplClickHdl, HyperLabel*, void); + + RoadmapItem* GetByIndex( ItemIndex _nItemIndex ); + const RoadmapItem* GetByIndex( ItemIndex _nItemIndex ) const; + + RoadmapItem* GetByID( ItemId _nID ); + const RoadmapItem* GetByID( ItemId _nID ) const; + RoadmapItem* GetPreviousHyperLabel( ItemIndex Index); + + void DrawHeadline(vcl::RenderContext& rRenderContext); + void DeselectOldRoadmapItems(); + ItemId GetNextAvailableItemId( ItemIndex NewIndex ); + ItemId GetPreviousAvailableItemId( ItemIndex NewIndex ); + RoadmapItem* GetByPointer(vcl::Window const * pWindow); + RoadmapItem* InsertHyperLabel( ItemIndex Index, const OUString& _aStr, ItemId RMID, bool _bEnabled, bool _bIncomplete ); + void UpdatefollowingHyperLabels( ItemIndex Index ); + + // Window overridables + void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& _rRect) override; + void implInit(vcl::RenderContext& rRenderContext); + + std::unique_ptr<RoadmapImpl> m_pImpl; +}; + +} // namespace vcl + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/spin.hxx b/include/vcl/toolkit/spin.hxx new file mode 100644 index 000000000..cc68f9d87 --- /dev/null +++ b/include/vcl/toolkit/spin.hxx @@ -0,0 +1,101 @@ +/* -*- 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_SPIN_HXX +#define INCLUDED_VCL_SPIN_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/ctrl.hxx> +#include <vcl/timer.hxx> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) SpinButton final : public Control +{ +private: + AutoTimer maRepeatTimer; + tools::Rectangle maUpperRect; + tools::Rectangle maLowerRect; + tools::Rectangle maFocusRect; + bool mbRepeat : 1; + bool mbUpperIn : 1; + bool mbLowerIn : 1; + bool mbInitialUp : 1; + bool mbInitialDown : 1; + bool mbHorz : 1; + bool mbUpperIsFocused : 1; + long mnMinRange; + long mnMaxRange; + long mnValue; + long mnValueStep; + + SAL_DLLPRIVATE tools::Rectangle* ImplFindPartRect( const Point& rPt ); + using Window::ImplInit; + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle ); + DECL_DLLPRIVATE_LINK( ImplTimeout, Timer*, void ); + +public: + explicit SpinButton( vcl::Window* pParent, WinBits nStyle ); + + void Up(); + void Down(); + + virtual void Resize() override; + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) 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 StateChanged( StateChangedType nStateChange ) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + void SetValue( long nValue ); + long GetValue() const { return mnValue; } + void SetValueStep( long nNewStep ) { mnValueStep = nNewStep; } + long GetValueStep() const { return mnValueStep; } + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + +private: + // moves the focus to the upper or lower rect. Return sal_True if the focus rect actually changed. + SAL_DLLPRIVATE bool ImplMoveFocus( bool _bUpper ); + SAL_DLLPRIVATE void ImplCalcFocusRect( bool _bUpper ); + + SAL_DLLPRIVATE bool ImplIsUpperEnabled( ) const + { + return mnValue + mnValueStep <= mnMaxRange; + } + SAL_DLLPRIVATE bool ImplIsLowerEnabled( ) const + { + return mnValue >= mnMinRange + mnValueStep; + } +}; + +#endif // INCLUDED_VCL_SPIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/svtabbx.hxx b/include/vcl/toolkit/svtabbx.hxx new file mode 100644 index 000000000..17a0b3282 --- /dev/null +++ b/include/vcl/toolkit/svtabbx.hxx @@ -0,0 +1,216 @@ +/* -*- 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 . + */ +#pragma once + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <vcl/dllapi.h> +#include <vcl/treelistbox.hxx> +#include <vcl/accessibletableprovider.hxx> + +#include <tools/debug.hxx> + +#include <memory> +#include <vector> + +enum class SvTabJustify +{ + AdjustRight = static_cast<int>(SvLBoxTabFlags::ADJUST_RIGHT), + AdjustLeft = static_cast<int>(SvLBoxTabFlags::ADJUST_LEFT), + AdjustCenter = static_cast<int>(SvLBoxTabFlags::ADJUST_CENTER) +}; + +class VCL_DLLPUBLIC SvTabListBox : public SvTreeListBox +{ +private: + std::vector<SvLBoxTab> mvTabList; + OUString aCurEntry; + +protected: + static OUString GetToken( const OUString &sStr, sal_Int32 &nIndex ); + + virtual void SetTabs() override; + virtual void InitEntry(SvTreeListEntry*, const OUString&, const Image&, const Image&) override; + + OUString GetTabEntryText( sal_uLong nPos, sal_uInt16 nCol ) const; + SvTreeListEntry* GetEntryOnPos( sal_uLong _nEntryPos ) const; + SvTreeListEntry* GetChildOnPos( SvTreeListEntry* _pParent, sal_uLong _nEntryPos, sal_uLong& _rPos ) const; + +public: + SvTabListBox( vcl::Window* pParent, WinBits ); + virtual ~SvTabListBox() override; + virtual void dispose() override; + void SetTabs(sal_uInt16 nTabs, long const pTabPositions[], MapUnit = MapUnit::MapAppFont); + using SvTreeListBox::GetTab; + long GetLogicTab( sal_uInt16 nTab ); + + virtual SvTreeListEntry* InsertEntry( const OUString& rText, SvTreeListEntry* pParent = nullptr, + bool bChildrenOnDemand = false, + sal_uLong nPos=TREELIST_APPEND, void* pUserData = nullptr ) override; + + 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 ) override; + + virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent, + sal_uLong nPos, sal_uInt16 nCol, void* pUserData = nullptr ); + virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, const Image& rExpandedEntryBmp, + const Image& rCollapsedEntryBmp, SvTreeListEntry* pParent, + sal_uLong nPos = TREELIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = nullptr ); + + virtual OUString GetEntryText( SvTreeListEntry* pEntry ) const override; + static OUString GetEntryText( SvTreeListEntry*, sal_uInt16 nCol ); + OUString GetEntryText( sal_uLong nPos, sal_uInt16 nCol = 0xffff ) const; + using SvTreeListBox::SetEntryText; + OUString GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const; + sal_uLong GetEntryPos( const SvTreeListEntry* pEntry ) const; + + void SetTabJustify( sal_uInt16 nTab, SvTabJustify ); + void SetTabEditable( sal_uInt16 nTab, bool bEditable ); +}; + +// class SvHeaderTabListBox --------------------------------------------------- + +class HeaderBar; +namespace vcl { + struct SvHeaderTabListBoxImpl; +} + +class VCL_DLLPUBLIC SvHeaderTabListBox : public SvTabListBox, public vcl::IAccessibleTableProvider +{ +private: + typedef ::std::vector< css::uno::Reference< css::accessibility::XAccessible > > AccessibleChildren; + + bool m_bFirstPaint; + std::unique_ptr<::vcl::SvHeaderTabListBoxImpl> m_pImpl; + ::vcl::IAccessibleTabListBox* m_pAccessible; + AccessibleChildren m_aAccessibleChildren; + + DECL_DLLPRIVATE_LINK( ScrollHdl_Impl, SvTreeListBox*, void ); + DECL_DLLPRIVATE_LINK( CreateAccessibleHdl_Impl, HeaderBar*, void ); + + void RecalculateAccessibleChildren(); + +public: + SvHeaderTabListBox( vcl::Window* pParent, WinBits nBits ); + virtual ~SvHeaderTabListBox() override; + virtual void dispose() override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; + + void InitHeaderBar(HeaderBar* pHeaderBar); + HeaderBar* GetHeaderBar(); + static bool IsItemChecked( SvTreeListEntry* pEntry, sal_uInt16 nCol ); + + virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, SvTreeListEntry* pParent, + sal_uLong nPos, sal_uInt16 nCol, void* pUserData = nullptr ) override; + virtual SvTreeListEntry* InsertEntryToColumn( const OUString&, const Image& rExpandedEntryBmp, + const Image& rCollapsedEntryBmp, SvTreeListEntry* pParent, + sal_uLong nPos = TREELIST_APPEND, sal_uInt16 nCol = 0xffff, void* pUserData = nullptr ) override; + virtual sal_uLong Insert( SvTreeListEntry* pEnt,SvTreeListEntry* pPar,sal_uLong nPos=TREELIST_APPEND) override; + virtual sal_uLong Insert( SvTreeListEntry* pEntry, sal_uLong nRootPos = TREELIST_APPEND ) override; + + // Accessible ------------------------------------------------------------- + + bool IsCellCheckBox( long _nRow, sal_uInt16 _nColumn, TriState& _rState ); + + /** @return The count of the rows. */ + virtual long GetRowCount() const override; + /** @return The count of the columns. */ + virtual sal_uInt16 GetColumnCount() const override; + + /** @return The position of the current row. */ + virtual sal_Int32 GetCurrRow() const override; + /** @return The position of the current column. */ + virtual sal_uInt16 GetCurrColumn() const override; + + /** @return The description of a row. + @param _nRow The row which description is in demand. */ + virtual OUString GetRowDescription( sal_Int32 _nRow ) const override; + /** @return The description of a column. + @param _nColumn The column which description is in demand. */ + virtual OUString GetColumnDescription( sal_uInt16 _nColumn ) const override; + + /** @return <TRUE/>, if the object has a row header. */ + virtual bool HasRowHeader() const override; //GetColumnId + /** @return <TRUE/>, if the object can focus a cell. */ + virtual bool GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override; + + virtual void SetNoSelection() override; + using SvTabListBox::SelectAll; + virtual void SelectAll() override; + virtual void SelectRow( long _nRow, bool _bSelect = true, bool bExpand = true ) override; + virtual void SelectColumn( sal_uInt16 _nColumn, bool _bSelect = true ) override; + virtual sal_Int32 GetSelectedRowCount() const override; + virtual sal_Int32 GetSelectedColumnCount() const override; + /** @return <TRUE/>, if the row is selected. */ + virtual bool IsRowSelected( long _nRow ) const override; + virtual bool IsColumnSelected( long _nColumn ) const override; + virtual void GetAllSelectedRows( css::uno::Sequence< sal_Int32 >& _rRows ) const override; + virtual void GetAllSelectedColumns( css::uno::Sequence< sal_Int32 >& _rColumns ) const override; + + /** @return <TRUE/>, if the cell is visible. */ + virtual bool IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; + virtual OUString GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const override; + + virtual tools::Rectangle calcHeaderRect( bool _bIsColumnBar, bool _bOnScreen = true ) override; + virtual tools::Rectangle calcTableRect( bool _bOnScreen = true ) override; + virtual tools::Rectangle GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumn, bool _bIsHeader, bool _bOnScreen = true ) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumn ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleRowHeader( sal_Int32 _nRow ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) override; + + virtual sal_Int32 GetAccessibleControlCount() const override; + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessibleControl( sal_Int32 _nIndex ) override; + virtual bool ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) override; + + virtual bool ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) override; + virtual bool ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) override; + virtual bool ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) override; + + virtual OUString GetAccessibleObjectName( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override; + virtual OUString GetAccessibleObjectDescription( ::vcl::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const override; + virtual vcl::Window* GetWindowInstance() override; + + virtual void FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::vcl::AccessibleBrowseBoxObjType _eType ) const override; + virtual void FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumn ) const override; + virtual void GrabTableFocus() override; + + // OutputDevice + virtual bool GetGlyphBoundRects( const Point& rOrigin, const OUString& rStr, int nIndex, int nLen, MetricVector& rVector ) override; + + // Window + virtual tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const override; + virtual void GrabFocus() override; + virtual css::uno::Reference< css::accessibility::XAccessible > GetAccessible() override; + /** Creates and returns the accessible object of the whole BrowseBox. */ + virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; + virtual vcl::Window* GetAccessibleParentWindow() const override; + + virtual tools::Rectangle GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) override; + virtual sal_Int32 GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/tabdlg.hxx b/include/vcl/toolkit/tabdlg.hxx new file mode 100644 index 000000000..dc2e370c1 --- /dev/null +++ b/include/vcl/toolkit/tabdlg.hxx @@ -0,0 +1,52 @@ +/* -*- 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_TABDLG_HXX +#define INCLUDED_VCL_TABDLG_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/toolkit/dialog.hxx> + +class FixedLine; + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) TabDialog final : public Dialog +{ +private: + VclPtr<FixedLine> mpFixedLine; + bool mbPosControls; + + SAL_DLLPRIVATE void ImplInitTabDialogData(); + SAL_DLLPRIVATE void ImplPosControls(); + +public: + TabDialog( vcl::Window* pParent, WinBits nStyle ); + virtual ~TabDialog() override; + virtual void dispose() override; + + virtual void StateChanged( StateChangedType nStateChange ) override; +}; + +#endif // INCLUDED_VCL_TABDLG_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/throbber.hxx b/include/vcl/toolkit/throbber.hxx new file mode 100644 index 000000000..2159e3d14 --- /dev/null +++ b/include/vcl/toolkit/throbber.hxx @@ -0,0 +1,88 @@ +/* -*- 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_THROBBER_HXX +#define INCLUDED_VCL_THROBBER_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <vcl/dllapi.h> +#include <vcl/toolkit/imgctrl.hxx> +#include <vcl/timer.hxx> + +#include <vector> + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) Throbber final : public ImageControl +{ +public: + enum class ImageSet + { + /// default images, 16x16 pixels + N16px, + /// default images, 32x32 pixels + N32px, + /// default images, 64x64 pixels + N64px, + }; + +public: + Throbber(vcl::Window* i_parentWindow, WinBits i_style); + virtual ~Throbber() override; + virtual void dispose() override; + + // Properties + void setStepTime( sal_Int32 nStepTime ) { mnStepTime = nStepTime; } + sal_Int32 getStepTime() const { return mnStepTime; } + + void setRepeat( bool bRepeat ) { mbRepeat = bRepeat; } + bool getRepeat() const { return mbRepeat; } + + // animation control + void start(); + void stop(); + bool isRunning() const; + + void setImageList( ::std::vector< Image > const& i_images ); + + // default images + static ::std::vector< OUString > + getDefaultImageURLs( const ImageSet i_imageSet ); + +private: + // Window overridables + virtual void Resize() override; + + SAL_DLLPRIVATE void initImages(); + + ::std::vector< Image > maImageList; + + bool mbRepeat; + sal_Int32 mnStepTime; + sal_Int32 mnCurStep; + AutoTimer maWaitTimer; + + DECL_LINK( TimeOutHdl, Timer*, void ); +}; + +#endif // INCLUDED_VCL_THROBBER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/toolkit/unowrap.hxx b/include/vcl/toolkit/unowrap.hxx new file mode 100644 index 000000000..fe8a60b19 --- /dev/null +++ b/include/vcl/toolkit/unowrap.hxx @@ -0,0 +1,100 @@ +/* -*- 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_UNOWRAP_HXX +#define INCLUDED_VCL_UNOWRAP_HXX + +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#error "don't use this in new code" +#endif + +#include <config_options.h> +#include <com/sun/star/uno/Reference.h> +#include <vcl/dllapi.h> +#include <vcl/vclptr.hxx> + +namespace vcl { class Window; } +class OutputDevice; +class Menu; + +namespace com { +namespace sun { +namespace star { +namespace awt { + class XGraphics; + class XToolkit; + class XWindow; + class XWindowPeer; +} +} } } + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + class XAccessible; +}}}} + +class UNLESS_MERGELIBS(VCL_DLLPUBLIC) UnoWrapperBase +{ +public: + virtual void Destroy() = 0; + + // Toolkit + virtual css::uno::Reference< css::awt::XToolkit > GetVCLToolkit() = 0; + + // Graphics + virtual css::uno::Reference< css::awt::XGraphics > CreateGraphics( OutputDevice* pOutDev ) = 0; + virtual void ReleaseAllGraphics( OutputDevice* pOutDev ) = 0; + + // Window + virtual css::uno::Reference< css::awt::XWindowPeer> GetWindowInterface( vcl::Window* pWindow ) = 0; + virtual void SetWindowInterface( vcl::Window* pWindow, css::uno::Reference< css::awt::XWindowPeer > xIFace ) = 0; + virtual VclPtr<vcl::Window> GetWindow(const css::uno::Reference<css::awt::XWindow>& rxWindow) = 0; + + virtual void WindowDestroyed( vcl::Window* pWindow ) = 0; + + // Accessibility + virtual css::uno::Reference< css::accessibility::XAccessible > + CreateAccessible( Menu* pMenu, bool bIsMenuBar ) = 0; + + /** Get the application's UNO wrapper object. + + Note that this static function will only ever try to create UNO wrapper object once, and + if it fails then it will not ever try again, even if the function is called multiple times. + + @param bCreateIfNotExists Create the UNO wrapper object if it doesn't exist when true. + + @return UNO wrapper object. + */ + static UnoWrapperBase* GetUnoWrapper( bool bCreateIfNotExists = true ); + + /** Sets the application's UNO Wrapper object. + + @param pWrapper Pointer to UNO wrapper object. + */ + static void SetUnoWrapper( UnoWrapperBase* pWrapper ); + +protected: + ~UnoWrapperBase() {} +}; + +#endif // INCLUDED_VCL_UNOWRAP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/transfer.hxx b/include/vcl/transfer.hxx new file mode 100644 index 000000000..2ec7c340b --- /dev/null +++ b/include/vcl/transfer.hxx @@ -0,0 +1,519 @@ +/* -*- 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 <vcl/dllapi.h> +#include <tools/globname.hxx> +#include <tools/gen.hxx> +#include <tools/solar.h> +#include <sot/formats.hxx> +#include <sot/exchange.hxx> +#include <cppuhelper/implbase.hxx> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/datatransfer/XTransferable2.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <com/sun/star/datatransfer/clipboard/XClipboardOwner.hpp> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> +#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDragEvent.hpp> +#include <com/sun/star/datatransfer/dnd/DropTargetDropEvent.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSourceListener.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTargetListener.hpp> +#include <com/sun/star/embed/Aspects.hpp> +#include <memory> + +namespace com::sun::star::datatransfer::dnd { class XDragGestureRecognizer; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::datatransfer::dnd { class XDropTarget; } + +namespace tools { template <typename T> class SvRef; } +template <typename Arg, typename Ret> class Link; + +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 VCL_DLLPRIVATE 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<TransferableObjectDescriptor> mxObjDesc; + +protected: + ~TransferableHelper(); + + 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; + virtual sal_Bool SAL_CALL isComplex() 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<SotStorageStream>& 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(const css::uno::Reference<css::datatransfer::clipboard::XClipboard> &rClipboard) const; + void CopyToSelection(const css::uno::Reference<css::datatransfer::clipboard::XClipboard> &rClipboard) const; + + // convenience versions of the above which extract the XClipboard from the pWindow + void CopyToClipboard( vcl::Window *pWindow ) const; + void CopyToSelection( vcl::Window *pWindow ) const; + + void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions ); + + 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<TransferableObjectDescriptor> mxObjDesc; + std::unique_ptr<TransferableDataHelper_Impl> 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 ) noexcept; + 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<sal_Int8> GetSequence( SotClipboardFormatId nFormat, const OUString& rDestDoc ); + css::uno::Sequence<sal_Int8> GetSequence( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); + + bool GetSotStorageStream( SotClipboardFormatId nFormat, tools::SvRef<SotStorageStream>& rStreamRef ); + bool GetSotStorageStream( const css::datatransfer::DataFlavor& rFlavor, tools::SvRef<SotStorageStream>& rStreamRef ); + + css::uno::Reference<css::io::XInputStream> GetInputStream( SotClipboardFormatId nFormat, const OUString& rDestDoc ); + css::uno::Reference<css::io::XInputStream> GetInputStream( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ); + + static TransferableDataHelper CreateFromClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& rClipboard); + 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 SAL_DLLPRIVATE 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 SAL_DLLPRIVATE DropTargetListener : public cppu::WeakImplHelper< css::datatransfer::dnd::XDropTargetListener > + { + private: + + DropTargetHelper& mrParent; + std::unique_ptr<AcceptDropEvent> 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; + + const DataFlavorExVector& GetDataFlavorExVector() const {return maFormats; } + +}; + +struct TransferDataContainer_Impl; + +class VCL_DLLPUBLIC TransferDataContainer : public TransferableHelper +{ + std::unique_ptr<TransferDataContainer_Impl> pImpl; + + virtual void AddSupportedFormats() override; + virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; + +public: + + TransferDataContainer(); + virtual ~TransferDataContainer() override; + + void CopyINetBookmark( const INetBookmark& rBkmk ); + void CopyString( const OUString& rStr ); + void CopyString( SotClipboardFormatId nFmt, const OUString& rStr ); + + void CopyByteString( SotClipboardFormatId nFormatId, const OString& rStr ); + void CopyAnyData( SotClipboardFormatId nFormatId, const char* pData, sal_uLong nLen ); + + bool HasAnyData() const; + + using TransferableHelper::StartDrag; + void StartDrag( vcl::Window* pWindow, sal_Int8 nDragSourceActions, + const Link<sal_Int8,void>& rCallbck ); + virtual void DragFinished( sal_Int8 nDropAction ) override; +}; + +css::uno::Reference<css::datatransfer::clipboard::XClipboard> VCL_DLLPUBLIC GetSystemClipboard(); +css::uno::Reference<css::datatransfer::clipboard::XClipboard> VCL_DLLPUBLIC GetSystemPrimarySelection(); + +#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 000000000..46d3374d8 --- /dev/null +++ b/include/vcl/treelist.hxx @@ -0,0 +1,305 @@ +/* -*- 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 <vcl/dllapi.h> +#include <vcl/treelistentries.hxx> + +#include <tools/solar.h> +#include <tools/link.hxx> +#include <tools/contnr.hxx> + +#include <memory> + +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 +}; + +class SvTreeListEntry; +class SvListView; +class SvViewDataEntry; + +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 +{ + friend class SvListView; + + SvListView& mrOwnerListView; + sal_uLong nEntryCount; + + Link<SvTreeListEntry*, SvTreeListEntry*> aCloneLink; + Link<const SvSortData&, sal_Int32> aCompareLink; + SvSortMode eSortMode; + + 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* LastSelected( const SvListView*) const; + + sal_uLong GetChildSelectionCount( const SvListView*,SvTreeListEntry* pParent ) const; + + 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 ); + + SvTreeList(const SvTreeList&) = delete; + SvTreeList& operator= (const SvTreeList&) = delete; + + std::unique_ptr<SvTreeListEntry> pRootItem; + +public: + + SvTreeList() = delete; + SvTreeList(SvListView&); + ~SvTreeList(); + + void Broadcast( + SvListAction nActionId, + SvTreeListEntry* pEntry1=nullptr, + SvTreeListEntry* pEntry2=nullptr, + sal_uLong nPos=0 + ); + + void EnableInvalidate( bool bEnable ); + bool IsEnableInvalidate() const { return mbEnableInvalidate; } + + // 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<SvTreeListEntries::iterator, SvTreeListEntries::iterator> + 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<SvTreeListEntry*,SvTreeListEntry*>& rLink ) + { aCloneLink=rLink; } + + const Link<SvTreeListEntry*,SvTreeListEntry*>& GetCloneLink() const + { return aCloneLink; } + + SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ) const; // Calls the Clone Link + + 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<const SvSortData&, sal_Int32>& rLink ) { aCompareLink = rLink; } + void Resort(); +}; + +class VCL_DLLPUBLIC SvListView +{ + friend class SvTreeList; + + struct SAL_DLLPRIVATE Impl; + std::unique_ptr<Impl> m_pImpl; + +protected: + std::unique_ptr<SvTreeList> pModel; + + void ExpandListEntry( SvTreeListEntry* pParent ); + void CollapseListEntry( SvTreeListEntry* pParent ); + bool SelectListEntry( SvTreeListEntry* pEntry, bool bSelect ); + +public: + SvListView(); // Sets the Model to 0 + void dispose(); + virtual ~SvListView(); + void Clear(); + virtual void ModelNotification( + SvListAction nActionId, + SvTreeListEntry* pEntry1, + SvTreeListEntry* pEntry2, + sal_uLong nPos + ); + + sal_uLong GetVisibleCount() const + { return pModel->GetVisibleCount( const_cast<SvListView*>(this) ); } + + SvTreeListEntry* FirstVisible() const + { return pModel->FirstVisible(); } + + SvTreeListEntry* NextVisible( SvTreeListEntry* pEntry ) const + { return pModel->NextVisible(this,pEntry); } + + 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* 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); } + + bool IsEntryVisible( SvTreeListEntry* pEntry ) const + { return pModel->IsEntryVisible(this,pEntry); } + + bool IsExpanded( SvTreeListEntry* pEntry ) const; + bool IsAllExpanded( SvTreeListEntry* pEntry) const; + bool IsSelected(const SvTreeListEntry* pEntry) const; + void SetEntryFocus( SvTreeListEntry* pEntry, bool bFocus ); + const SvViewDataEntry* GetViewData( const SvTreeListEntry* pEntry ) const; + SvViewDataEntry* GetViewData( SvTreeListEntry* pEntry ); + bool HasViewData() const; + + virtual void InitViewData( SvViewDataEntry*, SvTreeListEntry* pEntry ); + + virtual void ModelHasCleared(); + virtual void ModelHasInserted( SvTreeListEntry* pEntry ); + virtual void ModelHasInsertedTree( SvTreeListEntry* pEntry ); + virtual void ModelIsMoving( SvTreeListEntry* pSource ); + 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 000000000..288314af8 --- /dev/null +++ b/include/vcl/treelistbox.hxx @@ -0,0 +1,735 @@ +/* -*- 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 <vcl/dllapi.h> + +#include <deque> +#include <memory> +#include <vector> + +#include <vcl/ctrl.hxx> +#include <vcl/accel.hxx> +#include <vcl/mnemonicengine.hxx> +#include <vcl/quickselectionengine.hxx> +#include <vcl/image.hxx> +#include <tools/gen.hxx> +#include <tools/contnr.hxx> +#include <vcl/treelist.hxx> +#include <vcl/transfer.hxx> +#include <vcl/idle.hxx> +#include <vcl/menu.hxx> +#include <o3tl/typed_flags_set.hxx> + +class SvTreeListBox; +class SvTreeListEntry; +struct SvViewDataItem; +class SvViewDataEntry; +class SvInplaceEdit2; +class SvLBoxString; +class SvImpLBox; +class SvLBoxButtonData; +class Timer; +class Edit; + +namespace utl { + class AccessibleStateSetHelper; +} + +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 + + SHOW_SELECTION = 0x0010, // Visualize selection state + // Item needs to be able to return the surrounding polygon (D'n'D cursor) + EDITABLE = 0x0020, // Item editable at the tabulator + FORCE = 0x0040, // 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<SvLBoxTabFlags> : is_typed_flags<SvLBoxTabFlags, 0x007f> {}; +} + +#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<SvTreeFlags> : is_typed_flags<SvTreeFlags, 0x1f> {}; +} + +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 VCL_DLLPUBLIC SvLBoxItem +{ +protected: + bool mbDisabled; + +public: + SvLBoxItem(); + virtual ~SvLBoxItem(); + virtual SvLBoxItemType GetType() const = 0; + virtual int CalcWidth(const SvTreeListBox* pView) const; + int GetWidth(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; + int GetWidth(const SvTreeListBox* pView, const SvViewDataEntry* pData, sal_uInt16 nItemPos); + int GetHeight(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; + static int GetHeight(const SvViewDataEntry* pData, sal_uInt16 nItemPos); + void Enable(bool bEnabled) { mbDisabled = !bEnabled; } + + 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<SvLBoxItem> Clone(SvLBoxItem const * pSource) const = 0; +}; + +enum class DragDropMode +{ + NONE = 0x0000, + CTRL_MOVE = 0x0001, + CTRL_COPY = 0x0002, + APP_COPY = 0x0004, + // Entries may be dropped via the uppermost Entry + // The DropTarget is 0 in that case + ENABLE_TOP = 0x0010, + ALL = 0x0017, +}; +namespace o3tl +{ + template<> struct typed_flags<DragDropMode> : is_typed_flags<DragDropMode, 0x0017> {}; +} + +enum class SvTreeListBoxFlags +{ + NONE = 0x0000, + IN_EDT = 0x0001, + EDT_ENABLED = 0x0002, + TARGEMPH_VIS = 0x0004, + EDTEND_CALLED = 0x0008, +}; +namespace o3tl +{ + template<> struct typed_flags<SvTreeListBoxFlags> : is_typed_flags<SvTreeListBoxFlags, 0x000f> {}; +} + +struct SvTreeListBoxImpl; + +typedef std::pair<vcl::RenderContext&, const SvTreeListEntry&> svtree_measure_args; +typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, const SvTreeListEntry&> svtree_render_args; + +class VCL_DLLPUBLIC SvTreeListBox + :public Control + ,public SvListView + ,public DropTargetHelper + ,public DragSourceHelper + ,public vcl::IMnemonicEntryList + ,public vcl::ISearchableStringList +{ + friend class SvImpLBox; + friend class SvLBoxString; + friend class IconViewImpl; + friend class TreeControlPeer; + friend class SalInstanceIconView; + friend class SalInstanceTreeView; + friend class SalInstanceEntryTreeView; + + std::unique_ptr<SvTreeListBoxImpl> mpImpl; + Link<SvTreeListBox*,void> aCheckButtonHdl; + Link<SvTreeListBox*,void> aScrolledHdl; + Link<SvTreeListBox*,void> aExpandedHdl; + Link<SvTreeListBox*,bool> aExpandingHdl; + Link<SvTreeListBox*,void> aSelectHdl; + Link<SvTreeListBox*,void> aDeselectHdl; + Link<const CommandEvent&, bool> aPopupMenuHdl; + Link<const HelpEvent&, bool> aTooltipHdl; + Link<svtree_render_args, void> aCustomRenderHdl; + Link<svtree_measure_args, Size> aCustomMeasureHdl; + + Image aPrevInsertedExpBmp; + Image aPrevInsertedColBmp; + Image aCurInsertedExpBmp; + Image aCurInsertedColBmp; + + short nContextBmpWidthMax; + short nEntryHeightOffs; + short nIndent; + short nFocusWidth; + 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. + bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does + + SvTreeListEntry* pHdlEntry; + + DragDropMode nDragDropMode; + DragDropMode nOldDragMode; + SelectionMode eSelMode; + sal_Int32 nMinWidthInChars; + + sal_Int8 mnDragAction; + + SvTreeListEntry* pEdEntry; + SvLBoxItem* pEdItem; + + rtl::Reference<TransferDataContainer> m_xTransferHelper; + +protected: + std::unique_ptr<SvImpLBox> pImpl; + short nColumns; + short nEntryHeight; + short nEntryWidth; + bool mbCenterAndClipText; + + Link<SvTreeListBox*,bool> aDoubleClickHdl; + SvTreeListEntry* pTargetEntry; + SvLBoxButtonData* pCheckButtonData; + std::vector<std::unique_ptr<SvLBoxTab>> aTabs; + SvTreeFlags nTreeFlags; + SvTreeListBoxFlags nImpFlags; + // Move/CopySelection: Position of the current Entry in SelectionList + sal_uInt16 nCurEntrySelPos; + +private: + 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 ); + + // after a checkbox entry is inserted, use this to get its width to support + // autowidth for the 1st checkbox column + VCL_DLLPRIVATE void CheckBoxInserted(SvTreeListEntry* pEntry); + + VCL_DLLPRIVATE void DrawCustomEntry(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const SvTreeListEntry& rEntry); + VCL_DLLPRIVATE Size MeasureCustomEntry(vcl::RenderContext& rRenderContext, const SvTreeListEntry& rEntry); + + void UnsetDropTarget(); + +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<SvInplaceEdit2> pEdCtrl; + void EditText( const OUString&, const tools::Rectangle&,const Selection&); + void CancelTextEditing(); + bool EditingCanceled() const; + + // 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<sal_Int8,void> 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.get(); + } + + 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; + 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 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 a 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 + <TRUE/> if the event has been consumed, <FALSE/> otherwise. + */ + bool HandleKeyInput( const KeyEvent& rKEvt ); + + void SetSelectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aSelectHdl=rNewHdl; } + void SetDeselectHdl( const Link<SvTreeListBox*,void>& rNewHdl ) {aDeselectHdl=rNewHdl; } + void SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& rNewHdl) {aDoubleClickHdl=rNewHdl;} + void SetExpandingHdl(const Link<SvTreeListBox*,bool>& rNewHdl){aExpandingHdl=rNewHdl;} + void SetExpandedHdl(const Link<SvTreeListBox*,void>& rNewHdl){aExpandedHdl=rNewHdl;} + void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { aPopupMenuHdl = rLink; } + void SetTooltipHdl(const Link<const HelpEvent&, bool>& rLink) { aTooltipHdl = rLink; } + void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { aCustomRenderHdl = rLink; } + void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { aCustomMeasureHdl = rLink; } + + void ExpandedHdl(); + 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 ); + + SvTreeListEntry* CloneEntry( SvTreeListEntry* pSource ); + + // Return value: TRISTATE_TRUE == Ok, TRISTATE_FALSE == Cancel, TRISTATE_INDET == Ok and Make visible moved entry + 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 + 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(const SvTreeListEntry* pEntry); + + SvTreeFlags GetTreeFlags() const {return nTreeFlags;} + + static OUString SearchEntryTextWithHeadTitle(SvTreeListEntry* pEntry); + + 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&); + + virtual void NotifyEndScroll(); + virtual void NotifyScrolled(); + void SetScrolledHdl( const Link<SvTreeListBox*,void>& 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; + + void CallImplEventListeners(VclEventId nEvent, void* pData); + + void ImplEditEntry( SvTreeListEntry* pEntry ); + + 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); + + 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 ); + + const Image& GetDefaultExpandedEntryBmp( ) const; + const Image& GetDefaultCollapsedEntryBmp( ) const; + + void SetDefaultExpandedEntryBmp( const Image& rBmp ); + void SetDefaultCollapsedEntryBmp( const Image& rBmp ); + + void SetCheckButtonState( SvTreeListEntry*, SvButtonState ); + 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<SvTreeListBox*,void>& rLink ) { aCheckButtonHdl=rLink; } + virtual void CheckButtonHdl(); + + void SetSublistOpenWithLeftRight(); // open/close sublist with cursor left/right + + 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 ) 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 ); + short GetEntryWidth() const { return nEntryWidth; } + void SetEntryWidth( short nWidth ); + Size GetOutputSizePixel() const; + short GetIndent() const { return nIndent; } + void SetSpaceBetweenEntries( short nSpace ); + Point GetEntryPosition(const 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(const SvTreeListEntry*, long nLine ); + // Respects indentation + sal_IntPtr GetTabPos(const SvTreeListEntry*, SvLBoxTab*); + void InvalidateEntry( SvTreeListEntry* ); + SvLBoxItem* GetItem( SvTreeListEntry*, long nX, SvLBoxTab** ppTab); + SvLBoxItem* GetItem( SvTreeListEntry*, long nX ); + + void SetDragDropMode( DragDropMode ); + void SetSelectionMode( SelectionMode ); + + bool Expand( SvTreeListEntry* pParent ); + bool Collapse( SvTreeListEntry* pParent ); + virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ); + sal_uLong SelectChildren( SvTreeListEntry* pParent, bool bSelect ); + void SelectAll( bool bSelect ); + + 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); + + sal_Int32 DefaultCompare(const SvLBoxString* pLeftText, const SvLBoxString* pRightText); + + DECL_LINK( DefaultCompare, const SvSortData&, sal_Int32 ); + virtual void ModelNotification( SvListAction nActionId, SvTreeListEntry* pEntry1, + SvTreeListEntry* pEntry2, sal_uLong nPos ) override; + + void EndSelection(); + + SvTreeListEntry* GetFirstEntryInView() const; + SvTreeListEntry* GetNextEntryInView(SvTreeListEntry*) const; + void ScrollToAbsPos( long nPos ); + + void ShowFocusRect( const SvTreeListEntry* pEntry ); + + virtual VclPtr<PopupMenu> CreateContextMenu(); + virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ); + + void EnableContextMenuHandling(); + + long getPreferredDimensions(std::vector<long> &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; } + + // Make single click "activate" a row like a double-click normally does + void SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; } + + void SetForceMakeVisible(bool bEnable); + + virtual FactoryFunction GetUITestFactory() const override; + + void SetDragHelper(rtl::Reference<TransferDataContainer>& rHelper, sal_uInt8 eDNDConstants); +}; + +#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 000000000..ffe0cb571 --- /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 <vector> +#include <memory> + +class SvTreeListEntry; +typedef std::vector<std::unique_ptr<SvTreeListEntry>> 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 000000000..8cc808bb0 --- /dev/null +++ b/include/vcl/treelistentry.hxx @@ -0,0 +1,131 @@ +/* -*- 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 <vcl/dllapi.h> +#include <tools/solar.h> +#include <tools/color.hxx> +#include <vcl/treelistbox.hxx> +#include <vcl/treelistentries.hxx> +#include <o3tl/typed_flags_set.hxx> + +#include <optional> +#include <vector> +#include <memory> + +// flags related to the model +enum class SvTLEntryFlags +{ + NONE = 0x0000, + CHILDREN_ON_DEMAND = 0x0001, + DISABLE_DROP = 0x0002, + // is set if RequestingChildren has not set any children + NO_NODEBMP = 0x0004, + // entry had or has children + HAD_CHILDREN = 0x0010, + SEMITRANSPARENT = 0x8000, // draw semi-transparent entry bitmaps +}; +namespace o3tl +{ + template<> struct typed_flags<SvTLEntryFlags> : is_typed_flags<SvTLEntryFlags, 0x8017> {}; +} + +class VCL_DLLPUBLIC SvTreeListEntry +{ + friend class SvTreeList; + friend class SvListView; + friend class SvTreeListBox; + + typedef std::vector<std::unique_ptr<SvLBoxItem>> ItemsType; + + SvTreeListEntry* pParent; + SvTreeListEntries m_Children; + sal_uLong nAbsPos; + sal_uLong nListPos; + sal_uInt32 mnExtraIndent; + ItemsType m_Items; + void* pUserData; + SvTLEntryFlags nEntryFlags; + Color maBackColor; + std::optional<Color> mxTextColor; + +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<SvLBoxItem> pItem); + void ReplaceItem(std::unique_ptr<SvLBoxItem> 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; + + SvTLEntryFlags GetFlags() const { return nEntryFlags;} + void SetFlags( SvTLEntryFlags nFlags ); + + void SetBackColor( const Color& rColor ) { maBackColor = rColor; } + const Color& GetBackColor() const { return maBackColor; } + + void SetTextColor( std::optional<Color> xColor ) { mxTextColor = xColor; } + std::optional<Color> const & GetTextColor() const { return mxTextColor; } + + void SetExtraIndent(sal_uInt32 nExtraIndent) { mnExtraIndent = nExtraIndent; } + sal_uInt32 GetExtraIndent() const { return mnExtraIndent; } + + 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/txtattr.hxx b/include/vcl/txtattr.hxx new file mode 100644 index 000000000..479cfbe8d --- /dev/null +++ b/include/vcl/txtattr.hxx @@ -0,0 +1,189 @@ +/* -*- 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_TXTATTR_HXX +#define INCLUDED_VCL_TXTATTR_HXX + +#include <tools/color.hxx> +#include <tools/debug.hxx> +#include <tools/fontenum.hxx> +#include <vcl/dllapi.h> +#include <memory> + +namespace vcl { class Font; } + +#define TEXTATTR_FONTCOLOR 1 +#define TEXTATTR_FONTWEIGHT 3 + +#define TEXTATTR_USER_START 1000 //start id for user defined text attributes +#define TEXTATTR_PROTECTED 4 + + +class VCL_DLLPUBLIC TextAttrib +{ +private: + sal_uInt16 const mnWhich; + +protected: + TextAttrib( sal_uInt16 nWhich ) : mnWhich(nWhich) {} + TextAttrib( const TextAttrib& ) = default; + +public: + + virtual ~TextAttrib(); + + sal_uInt16 Which() const { return mnWhich; } + virtual void SetFont( vcl::Font& rFont ) const = 0; + virtual std::unique_ptr<TextAttrib> Clone() const = 0; + + virtual bool operator==( const TextAttrib& rAttr ) const = 0; + bool operator!=( const TextAttrib& rAttr ) const + { return !(*this == rAttr ); } +}; + + +class VCL_DLLPUBLIC TextAttribFontColor final : public TextAttrib +{ +private: + Color maColor; + +public: + TextAttribFontColor( const Color& rColor ); + + const Color& GetColor() const { return maColor; } + + virtual void SetFont( vcl::Font& rFont ) const override; + virtual std::unique_ptr<TextAttrib> Clone() const override; + virtual bool operator==( const TextAttrib& rAttr ) const override; + +}; + +class VCL_DLLPUBLIC TextAttribFontWeight final : public TextAttrib +{ +private: + FontWeight meWeight; + +public: + TextAttribFontWeight( FontWeight eWeight ); + + virtual void SetFont( vcl::Font& rFont ) const override; + virtual std::unique_ptr<TextAttrib> Clone() const override; + virtual bool operator==( const TextAttrib& rAttr ) const override; + + FontWeight getFontWeight() const { return meWeight; } +}; + +class TextAttribProtect final : public TextAttrib +{ +public: + TextAttribProtect(); + + virtual void SetFont( vcl::Font& rFont ) const override; + virtual std::unique_ptr<TextAttrib> Clone() const override; + virtual bool operator==( const TextAttrib& rAttr ) const override; + +}; + + +class TextCharAttrib +{ +private: + std::unique_ptr<TextAttrib> + mpAttr; + sal_Int32 mnStart; + sal_Int32 mnEnd; + +public: + TextCharAttrib( const TextAttrib& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); + TextCharAttrib( const TextCharAttrib& rTextCharAttrib ); + + const TextAttrib& GetAttr() const { return *mpAttr; } + + sal_uInt16 Which() const { return mpAttr->Which(); } + + sal_Int32 GetStart() const { return mnStart; } + void SetStart(sal_Int32 n) { mnStart = n; } + + sal_Int32 GetEnd() const { return mnEnd; } + void SetEnd(sal_Int32 n) { mnEnd = n; } + + inline sal_Int32 GetLen() const; + + inline void MoveForward( sal_Int32 nDiff ); + inline void MoveBackward( sal_Int32 nDiff ); + + inline void Expand( sal_Int32 nDiff ); + inline void Collaps( sal_Int32 nDiff ); + + inline bool IsIn( sal_Int32 nIndex ); + inline bool IsInside( sal_Int32 nIndex ); + inline bool IsEmpty() const; + +}; + +inline sal_Int32 TextCharAttrib::GetLen() const +{ + DBG_ASSERT( mnEnd >= mnStart, "TextCharAttrib: nEnd < nStart!" ); + return mnEnd-mnStart; +} + +inline void TextCharAttrib::MoveForward( sal_Int32 nDiff ) +{ + DBG_ASSERT( nDiff <= SAL_MAX_INT32-mnEnd, "TextCharAttrib: MoveForward?!" ); + mnStart = mnStart + nDiff; + mnEnd = mnEnd + nDiff; +} + +inline void TextCharAttrib::MoveBackward( sal_Int32 nDiff ) +{ + DBG_ASSERT( mnStart >= nDiff, "TextCharAttrib: MoveBackward?!" ); + mnStart = mnStart - nDiff; + mnEnd = mnEnd - nDiff; +} + +inline void TextCharAttrib::Expand( sal_Int32 nDiff ) +{ + DBG_ASSERT( nDiff <= SAL_MAX_INT32-mnEnd, "TextCharAttrib: Expand?!" ); + mnEnd = mnEnd + nDiff; +} + +inline void TextCharAttrib::Collaps( sal_Int32 nDiff ) +{ + DBG_ASSERT( mnEnd-mnStart >= nDiff, "TextCharAttrib: Collaps?!" ); + mnEnd = mnEnd - nDiff; +} + +inline bool TextCharAttrib::IsIn( sal_Int32 nIndex ) +{ + return ( ( mnStart <= nIndex ) && ( mnEnd >= nIndex ) ); +} + +inline bool TextCharAttrib::IsInside( sal_Int32 nIndex ) +{ + return ( ( mnStart < nIndex ) && ( mnEnd > nIndex ) ); +} + +inline bool TextCharAttrib::IsEmpty() const +{ + return mnStart == mnEnd; +} + +#endif // INCLUDED_VCL_TXTATTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/eventdescription.hxx b/include/vcl/uitest/eventdescription.hxx new file mode 100644 index 000000000..47bf9e117 --- /dev/null +++ b/include/vcl/uitest/eventdescription.hxx @@ -0,0 +1,24 @@ +/* -*- 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_UITEST_EVENTDESCRIPTION_HXX +#define INCLUDED_VCL_UITEST_EVENTDESCRIPTION_HXX + +#include <rtl/ustring.hxx> +#include <map> + +struct EventDescription +{ + OUString aKeyWord, aAction, aID, aParent; + std::map<OUString, OUString> aParameters; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/factory.hxx b/include/vcl/uitest/factory.hxx new file mode 100644 index 000000000..3319c5e18 --- /dev/null +++ b/include/vcl/uitest/factory.hxx @@ -0,0 +1,28 @@ +/* -*- 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_UITEST_FACTORY_HXX +#define INCLUDED_VCL_UITEST_FACTORY_HXX + +#include <memory> +#include <functional> + +namespace vcl { + +class Window; + +} + +class UIObject; + +typedef std::function<std::unique_ptr<UIObject>(vcl::Window*)> FactoryFunction; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/formattedfielduiobject.hxx b/include/vcl/uitest/formattedfielduiobject.hxx new file mode 100644 index 000000000..2408fe753 --- /dev/null +++ b/include/vcl/uitest/formattedfielduiobject.hxx @@ -0,0 +1,37 @@ +/* -*- 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_UITEST_FORMATTEDFIELDUIOBJECT_HXX +#define INCLUDED_VCL_UITEST_FORMATTEDFIELDUIOBJECT_HXX + +#include <vcl/uitest/uiobject.hxx> + +class FormattedField; + +class UITEST_DLLPUBLIC FormattedFieldUIObject : public SpinFieldUIObject +{ + VclPtr<FormattedField> mxFormattedField; + +public: + FormattedFieldUIObject(const VclPtr<FormattedField>& xEdit); + virtual ~FormattedFieldUIObject() override; + + virtual void execute(const OUString& rAction, const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +protected: + virtual OUString get_name() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx new file mode 100644 index 000000000..8bda35488 --- /dev/null +++ b/include/vcl/uitest/logger.hxx @@ -0,0 +1,81 @@ +/* -*- 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_UITEST_LOGGER_HXX +#define INCLUDED_VCL_UITEST_LOGGER_HXX + +#include <vcl/dllapi.h> + +#include <tools/stream.hxx> +#include <vcl/vclevent.hxx> + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace beans +{ +struct PropertyValue; +} +} +} +} +namespace com +{ +namespace sun +{ +namespace star +{ +namespace uno +{ +template <class E> class Sequence; +} +} +} +} + +struct EventDescription; +class Control; +class KeyEvent; + +class UITEST_DLLPUBLIC UITestLogger +{ +private: + SvFileStream maStream; + + bool mbValid; + + OUString app_name; + +public: + UITestLogger(); + + void logCommand(const OUString& rAction, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + + void logAction(VclPtr<Control> const& xUIElement, VclEventId nEvent); + + void log(const OUString& rString); + + void logKeyInput(VclPtr<vcl::Window> const& xUIElement, const KeyEvent& rEvent); + + void logEvent(const EventDescription& rDescription); + + static UITestLogger& getInstance(); + + void setAppName(OUString name) { app_name = name; } + + OUString getAppName() const { return app_name; } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/metricfielduiobject.hxx b/include/vcl/uitest/metricfielduiobject.hxx new file mode 100644 index 000000000..21ff7ac88 --- /dev/null +++ b/include/vcl/uitest/metricfielduiobject.hxx @@ -0,0 +1,37 @@ +/* -*- 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_UITEST_METRICFIELDUIOBJECT_HXX +#define INCLUDED_VCL_UITEST_METRICFIELDUIOBJECT_HXX + +#include <vcl/uitest/uiobject.hxx> + +class MetricField; + +class UITEST_DLLPUBLIC MetricFieldUIObject : public SpinFieldUIObject +{ + VclPtr<MetricField> mxMetricField; + +public: + MetricFieldUIObject(const VclPtr<MetricField>& xEdit); + virtual ~MetricFieldUIObject() override; + + virtual void execute(const OUString& rAction, const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +protected: + virtual OUString get_name() const override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/uiobject.hxx b/include/vcl/uitest/uiobject.hxx new file mode 100644 index 000000000..2c9a3e36c --- /dev/null +++ b/include/vcl/uitest/uiobject.hxx @@ -0,0 +1,462 @@ +/* -*- 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_UITEST_UIOBJECT_HXX +#define INCLUDED_VCL_UITEST_UIOBJECT_HXX + +#include <rtl/ustring.hxx> +#include <map> +#include <memory> + +#include <vcl/window.hxx> +#include <vcl/dllapi.h> + +#include <set> + +class Button; +class CheckBox; +class ComboBox; +class Dialog; +class Edit; +class ListBox; +class RadioButton; +class TabControl; +class TabPage; +class SvTreeListBox; +class SvTreeListEntry; +class SpinButton; +class SpinField; +class VclMultiLineEdit; + +typedef std::map<const OUString, OUString> StringMap; + +/** + * This class wraps a UI object like vcl::Window and provides + * an interface for the UI testing. + * + * This class should only have virtual methods. + */ +class UITEST_DLLPUBLIC UIObject +{ + UIObject(UIObject const &) = delete; + UIObject& operator =(UIObject const &) = delete; + +public: + UIObject() = default; + + virtual ~UIObject(); + + /** + * Returns the state of the wrapped UI object as a + * string key value map. + */ + virtual StringMap get_state(); + + /** + * Executes an action on the wrapped UI object, + * possibly with some additional parameters + */ + virtual void execute(const OUString& rAction, + const StringMap& rParameters); + + /** + * Returns the type of the UIObject. Additional information might + * be available through UIObject::get_state(). + */ + virtual OUString get_type() const; + + /** + * Returns the child of the current UIObject with the corresponding id. + * If no object with that id is being found returns a nullptr. + * + */ + virtual std::unique_ptr<UIObject> get_child(const OUString& rID); + + /** + * Returns a set containing all descendants of the object. + */ + virtual std::set<OUString> get_children() const; + + /** + * Currently an internal method to dump the state of the current UIObject as represented by get_state(). + * + * This method should not be exposed to the outside world. + * + */ + virtual OUString dumpState() const; + + /** + * Currently an internal method to dump the parent-child relationship starting from the current top focus window. + * + * This method should not be exposed to the outside world. + * + */ + virtual OUString dumpHierarchy() const; + + /** + * Gets the corresponding Action string for the event. + */ + virtual OUString get_action(VclEventId nEvent) const; +}; + +class UITEST_DLLPUBLIC WindowUIObject : public UIObject +{ + VclPtr<vcl::Window> mxWindow; + +public: + + WindowUIObject(const VclPtr<vcl::Window>& xWindow); + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual OUString get_type() const override; + + virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override; + + virtual std::set<OUString> get_children() const override; + + virtual OUString dumpState() const override; + + virtual OUString dumpHierarchy() const override; + + virtual OUString get_action(VclEventId nEvent) const override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +protected: + + virtual OUString get_name() const; + +}; + +// TODO: moggi: what about push buttons? +class ButtonUIObject final : public WindowUIObject +{ + VclPtr<Button> mxButton; +public: + + ButtonUIObject(const VclPtr<Button>& xButton); + virtual ~ButtonUIObject() override; + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class DialogUIObject final : public WindowUIObject +{ + VclPtr<Dialog> mxDialog; + +public: + + DialogUIObject(const VclPtr<Dialog>& xDialog); + virtual ~DialogUIObject() override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +private: + + virtual OUString get_name() const override; +}; + +class EditUIObject : public WindowUIObject +{ + VclPtr<Edit> mxEdit; + +public: + + EditUIObject(const VclPtr<Edit>& xEdit); + virtual ~EditUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +protected: + + virtual OUString get_name() const override; +}; + +class MultiLineEditUIObject final : public WindowUIObject +{ + VclPtr<VclMultiLineEdit> mxEdit; + +public: + + MultiLineEditUIObject(const VclPtr<VclMultiLineEdit>& xEdit); + virtual ~MultiLineEditUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +private: + + virtual OUString get_name() const override; +}; + +// TODO: moggi: maybe let it inherit from the button case +class CheckBoxUIObject final : public WindowUIObject +{ +private: + VclPtr<CheckBox> mxCheckBox; + +public: + CheckBoxUIObject(const VclPtr<CheckBox>& xCheckbox); + virtual ~CheckBoxUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class RadioButtonUIObject final : public WindowUIObject +{ +private: + VclPtr<RadioButton> mxRadioButton; + +public: + RadioButtonUIObject(const VclPtr<RadioButton>& xCheckbox); + virtual ~RadioButtonUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class TabPageUIObject final : public WindowUIObject +{ +private: + VclPtr<TabPage> mxTabPage; +public: + TabPageUIObject(const VclPtr<TabPage>& xTabPage); + virtual ~TabPageUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + +private: + + virtual OUString get_name() const override; +}; + +class ListBoxUIObject final : public WindowUIObject +{ +private: + VclPtr<ListBox> mxListBox; + +public: + + ListBoxUIObject(const VclPtr<ListBox>& xListBox); + virtual ~ListBoxUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +// TODO: moggi: should it inherit from EditUIObject? +class ComboBoxUIObject final : public WindowUIObject +{ +private: + VclPtr<ComboBox> mxComboBox; + +public: + + ComboBoxUIObject(const VclPtr<ComboBox>& xListBox); + virtual ~ComboBoxUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class SpinUIObject final : public WindowUIObject +{ +private: + VclPtr<SpinButton> mxSpinButton; + +public: + + SpinUIObject(const VclPtr<SpinButton>& xSpinButton); + virtual ~SpinUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class SpinFieldUIObject : public EditUIObject +{ + VclPtr<SpinField> mxSpinField; + +public: + + SpinFieldUIObject(const VclPtr<SpinField>& xEdit); + virtual ~SpinFieldUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class TabControlUIObject final : public WindowUIObject +{ +private: + VclPtr<TabControl> mxTabControl; + +public: + + TabControlUIObject(const VclPtr<TabControl>& mxTabControl); + virtual ~TabControlUIObject() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual OUString get_action(VclEventId nEvent) const override; + +private: + + virtual OUString get_name() const override; +}; + +class TreeListUIObject final : public WindowUIObject +{ +public: + TreeListUIObject(const VclPtr<SvTreeListBox>& xTreeList); + + virtual StringMap get_state() override; + + static std::unique_ptr<UIObject> create(vcl::Window* pWindow); + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override; + + virtual std::set<OUString> get_children() const override; + +private: + + virtual OUString get_name() const override; + + VclPtr<SvTreeListBox> mxTreeList; +}; + +class TreeListEntryUIObject final : public UIObject +{ +public: + + TreeListEntryUIObject(const VclPtr<SvTreeListBox>& xTreeList, SvTreeListEntry* pEntry); + + virtual StringMap get_state() override; + + virtual void execute(const OUString& rAction, + const StringMap& rParameters) override; + + virtual std::unique_ptr<UIObject> get_child(const OUString& rID) override; + + virtual std::set<OUString> get_children() const override; + + virtual OUString get_type() const override; + +private: + + VclPtr<SvTreeListBox> mxTreeList; + + SvTreeListEntry* const mpEntry; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/uitest/uitest.hxx b/include/vcl/uitest/uitest.hxx new file mode 100644 index 000000000..4b9ca92f4 --- /dev/null +++ b/include/vcl/uitest/uitest.hxx @@ -0,0 +1,42 @@ +/* -*- 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_UITEST_UITEST_HXX +#define INCLUDED_VCL_UITEST_UITEST_HXX + +#include <rtl/ustring.hxx> + +#include <vcl/dllapi.h> + +#include <memory> + +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::uno { template <typename > class Sequence; } + +class UIObject; + +class UITest +{ +public: + + static bool executeCommand(const OUString& rCommand); + + static bool executeCommandWithParameters(const OUString& rCommand, + const css::uno::Sequence< css::beans::PropertyValue >& rArgs); + + static bool executeDialog(const OUString& rCommand); + + static std::unique_ptr<UIObject> getFocusTopWindow(); + + static std::unique_ptr<UIObject> getFloatWindow(); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/unohelp.hxx b/include/vcl/unohelp.hxx new file mode 100644 index 000000000..ab00fff5d --- /dev/null +++ b/include/vcl/unohelp.hxx @@ -0,0 +1,61 @@ +/* -*- 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_UNOHELP_HXX +#define INCLUDED_VCL_UNOHELP_HXX + +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/awt/FontSlant.hpp> +#include <tools/fontenum.hxx> +#include <vcl/dllapi.h> + +namespace com { +namespace sun { +namespace star { +namespace i18n { + class XBreakIterator; + class XCharacterClassification; +}}}} + +namespace com { +namespace sun { +namespace star { +namespace accessibility { + struct AccessibleEventObject; +} +}}} + +namespace vcl +{ +namespace unohelper +{ +VCL_DLLPUBLIC css::uno::Reference < css::i18n::XBreakIterator > CreateBreakIterator(); +VCL_DLLPUBLIC css::uno::Reference < css::i18n::XCharacterClassification> CreateCharacterClassification(); +VCL_DLLPUBLIC void NotifyAccessibleStateEventGlobally( const css::accessibility::AccessibleEventObject& rEventObject ); +VCL_DLLPUBLIC float ConvertFontWidth( FontWidth eWidth ); +VCL_DLLPUBLIC FontWidth ConvertFontWidth( float f ); +VCL_DLLPUBLIC float ConvertFontWeight( FontWeight eWeight ); +VCL_DLLPUBLIC FontWeight ConvertFontWeight( float f ); +VCL_DLLPUBLIC css::awt::FontSlant ConvertFontSlant( FontItalic eWeight ); +VCL_DLLPUBLIC FontItalic ConvertFontSlant( css::awt::FontSlant ); +}} // namespace vcl::unohelper + +#endif // INCLUDED_VCL_UNOHELP_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/unohelp2.hxx b/include/vcl/unohelp2.hxx new file mode 100644 index 000000000..a95474417 --- /dev/null +++ b/include/vcl/unohelp2.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_UNOHELP2_HXX +#define INCLUDED_VCL_UNOHELP2_HXX + +#include <com/sun/star/datatransfer/XTransferable.hpp> +#include <cppuhelper/weak.hxx> +#include <rtl/ustring.hxx> +#include <osl/mutex.hxx> +#include <vcl/dllapi.h> + +namespace com::sun::star::datatransfer::clipboard { + class XClipboard; +} + +namespace vcl::unohelper { + + class VCL_DLLPUBLIC TextDataObject final : + public css::datatransfer::XTransferable, + public ::cppu::OWeakObject + { + private: + OUString maText; + + public: + TextDataObject( const OUString& rText ); + virtual ~TextDataObject() override; + + // css::uno::XInterface + css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override; + void SAL_CALL acquire() throw() override { OWeakObject::acquire(); } + void SAL_CALL release() throw() override { OWeakObject::release(); } + + // css::datatransfer::XTransferable + css::uno::Any SAL_CALL getTransferData( const css::datatransfer::DataFlavor& aFlavor ) override; + css::uno::Sequence< css::datatransfer::DataFlavor > SAL_CALL getTransferDataFlavors( ) override; + sal_Bool SAL_CALL isDataFlavorSupported( const css::datatransfer::DataFlavor& aFlavor ) override; + + /// copies a given string to a given clipboard + static void CopyStringTo( + const OUString& rContent, + const css::uno::Reference< css::datatransfer::clipboard::XClipboard >& rxClipboard + ); + }; + + struct MutexHelper + { + private: + ::osl::Mutex maMutex; + public: + ::osl::Mutex& GetMutex() { return maMutex; } + }; + +} // namespace vcl::unohelper + +#endif // INCLUDED_VCL_UNOHELP2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclenum.hxx b/include/vcl/vclenum.hxx new file mode 100644 index 000000000..8d808809c --- /dev/null +++ b/include/vcl/vclenum.hxx @@ -0,0 +1,346 @@ +/* -*- 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_VCLENUM_HXX +#define INCLUDED_VCL_VCLENUM_HXX + +#include <sal/types.h> +#include <o3tl/typed_flags_set.hxx> + +enum class SelectionMode { NONE, Single, Range, Multiple }; + +enum class TimeFieldFormat : sal_Int32 { F_NONE, F_SEC, F_SEC_CS }; + +enum class MenuItemType { DONTKNOW, STRING, IMAGE, STRINGIMAGE, SEPARATOR }; + +enum class MenuItemBits : sal_Int16 +{ + NONE = 0x0000, + CHECKABLE = 0x0001, + RADIOCHECK = 0x0002, + AUTOCHECK = 0x0004, + HELP = 0x0010, + POPUPSELECT = 0x0020, + // These have been said to be a preliminary (sic) solution since 2007 + NOSELECT = 0x0040, + ICON = 0x0080, + TEXT = 0x0100, +}; +namespace o3tl +{ + template<> struct typed_flags<MenuItemBits> : is_typed_flags<MenuItemBits, 0x1f7> {}; +} + +enum class ToolBoxItemBits +{ + NONE = 0x0000, + CHECKABLE = 0x0001, + RADIOCHECK = 0x0002, + AUTOCHECK = 0x0004, + LEFT = 0x0008, + AUTOSIZE = 0x0010, + DROPDOWN = 0x0020, + REPEAT = 0x0040, + DROPDOWNONLY = 0x00a0, // 0x0080 | DROPDOWN + TEXT_ONLY = 0x0100, + ICON_ONLY = 0x0200 +}; +namespace o3tl +{ + template<> struct typed_flags<ToolBoxItemBits> : is_typed_flags<ToolBoxItemBits, 0x3ff> {}; +} + +enum class ToolBoxItemType { DONTKNOW, BUTTON, SPACE, SEPARATOR, BREAK }; + +enum class ButtonType { SYMBOLONLY, TEXT, SYMBOLTEXT }; + +enum class SymbolType : sal_uInt16 +{ + DONTKNOW = 0, + IMAGE = 1, + ARROW_UP = 2, + ARROW_DOWN = 3, + ARROW_LEFT = 4, + ARROW_RIGHT = 5, + SPIN_UP = 6, + SPIN_DOWN = 7, + SPIN_LEFT = 8, + SPIN_RIGHT = 9, + FIRST = 10, + LAST = 11, + PREV = 12, + NEXT = 13, + PAGEUP = 14, + PAGEDOWN = 15, + PLAY = 16, + STOP = 19, + CLOSE = 25, + ROLLUP = 26, + ROLLDOWN = 27, + CHECKMARK = 28, + RADIOCHECKMARK = 29, + FLOAT = 31, + DOCK = 32, + HIDE = 33, + HELP = 34, + PLUS = 35, + MENU = SymbolType::SPIN_DOWN +}; + + +// Border styles for SetBorder() +enum class WindowBorderStyle : sal_Int16 +{ + NONE = 0x0000, + NORMAL = 0x0001, + MONO = 0x0002, + MENU = 0x0010, + NWF = 0x0020, + NOBORDER = 0x1000, + REMOVEBORDER = 0x2000 +}; +namespace o3tl +{ + template<> struct typed_flags<WindowBorderStyle> : is_typed_flags<WindowBorderStyle, 0x3033> {}; +} + +enum class WindowStateMask { + NONE = 0x0000, + X = 0x0001, + Y = 0x0002, + Width = 0x0004, + Height = 0x0008, + State = 0x0010, + Minimized = 0x0020, + MaximizedX = 0x0100, + MaximizedY = 0x0200, + MaximizedWidth = 0x0400, + MaximizedHeight = 0x0800, + Pos = X | Y, + All = X | Y | Width | Height | MaximizedX | MaximizedY | MaximizedWidth | MaximizedHeight | State | Minimized +}; +namespace o3tl +{ + template<> struct typed_flags<WindowStateMask> : is_typed_flags<WindowStateMask, 0x0f3f> {}; +} + +enum class TimeFormat +{ + Hour12, Hour24 +}; + +enum class ExtTimeFieldFormat +{ + /** the first 4 of these are only used by base/dbaccess */ + Short24H, Long24H, + Short12H, Long12H, + ShortDuration, LongDuration +}; + +enum class ExtDateFieldFormat +{ + SystemShort, SystemShortYY, SystemShortYYYY, + SystemLong, + ShortDDMMYY, ShortMMDDYY, ShortYYMMDD, + ShortDDMMYYYY, ShortMMDDYYYY, ShortYYYYMMDD, + ShortYYMMDD_DIN5008, ShortYYYYMMDD_DIN5008, + FORCE_EQUAL_SIZE=SAL_MAX_ENUM +}; + +// this appears to be a direct copy of css::awt::GradientStyle +enum class GradientStyle +{ + Linear = 0, + Axial = 1, + Radial = 2, + Elliptical = 3, + Square = 4, + Rect = 5, + FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +enum class HatchStyle +{ + Single = 0, + Double = 1, + Triple = 2, + FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +enum class LineStyle +{ + NONE = 0, + Solid = 1, + Dash = 2, + FORCE_EQUAL_SIZE = SAL_MAX_ENUM +}; + +enum class RasterOp { OverPaint, Xor, N0, N1, Invert }; + +typedef sal_uInt32 sal_UCS4; // TODO: this should be moved to rtl + +enum class OutDevSupportType { TransparentRect, B2DDraw }; + +struct ItalicMatrix +{ + double xx, xy, yx, yy; + ItalicMatrix() : xx(1), xy(0), yx(0), yy(1) {} +}; + +inline bool operator ==(const ItalicMatrix& a, const ItalicMatrix& b) +{ + return a.xx == b.xx && a.xy == b.xy && a.yx == b.yx && a.yy == b.yy; +} + +inline bool operator !=(const ItalicMatrix& a, const ItalicMatrix& b) +{ + return !(a == b); +} + +enum class VclAlign +{ + Fill, + Start, + End, + Center +}; + +enum class VclPackType +{ + Start = 0, + End = 1, + LAST = End +}; + +// Return Values from Dialog::Execute +//!!! in case of changes adjust /basic/source/runtime/methods.cxx msgbox + +enum VclResponseType +{ + RET_CANCEL = 0, + RET_OK = 1, + RET_YES = 2, + RET_NO = 3, + RET_RETRY = 4, + RET_IGNORE = 5, + RET_CLOSE = 7, + RET_HELP = 10 +}; + +enum class VclButtonsType +{ + NONE, + Ok, + Close, + Cancel, + YesNo, + OkCancel +}; + +enum class VclMessageType +{ + Info, + Warning, + Question, + Error, + Other +}; + +enum class VclSizeGroupMode +{ + NONE, + Horizontal, + Vertical, + Both +}; + +enum class VclPolicyType +{ + ALWAYS, + AUTOMATIC, + NEVER +}; + +enum class WizardButtonFlags : sal_Int16 +{ + NONE = 0x0000, + NEXT = 0x0001, + PREVIOUS = 0x0002, + FINISH = 0x0004, + CANCEL = 0x0008, + HELP = 0x0010, +}; + +namespace o3tl +{ + template<> struct typed_flags<WizardButtonFlags> : is_typed_flags<WizardButtonFlags, 0x001f> {}; +} + +// small, large, size32 force an exact toolbox size for proper alignment +// DontCare will let the toolbox decide about its size +enum class ToolBoxButtonSize +{ + DontCare, + Small, + Large, + Size32, +}; + +enum class WindowStateState { + NONE = 0x0000, + Normal = 0x0001, + Minimized = 0x0002, + Maximized = 0x0004, + Rollup = 0x0008, + MaximizedHorz = 0x0010, + MaximizedVert = 0x0020, + FullScreen = 0x0040, + SystemMask = 0xffff +}; +namespace o3tl +{ + template<> struct typed_flags<WindowStateState> : is_typed_flags<WindowStateState, 0xffff> {}; +} + +namespace vcl +{ + enum class ImageType + { + Size16, + Size26, + Size32, + Small = Size16, + LAST = Size32, + }; +} + +enum class DrawFrameStyle +{ + NONE = 0x0000, + In = 0x0001, + Out = 0x0002, + Group = 0x0003, + DoubleIn = 0x0004, + DoubleOut = 0x0005, + NWF = 0x0006, +}; + +#endif // INCLUDED_VCL_VCLENUM_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclevent.hxx b/include/vcl/vclevent.hxx new file mode 100644 index 000000000..170cd40ec --- /dev/null +++ b/include/vcl/vclevent.hxx @@ -0,0 +1,232 @@ +/* -*- 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_VCLEVENT_HXX +#define INCLUDED_VCL_VCLEVENT_HXX + +#include <vcl/dllapi.h> +#include <vcl/vclptr.hxx> + +#include <com/sun/star/uno/Reference.hxx> + +class Menu; + +namespace com::sun::star::accessibility { + class XAccessible; +} + +namespace vcl +{ + class Window; +} + +enum class VclEventId +{ + NONE, + ApplicationDataChanged, // pData = DataChangedEvent* + ButtonClick, + CheckboxToggle, + ComboboxDeselect, + ComboboxDoubleClick, + ComboboxItemAdded, // pData = itempos + ComboboxItemRemoved, // pData = itempos, -1=All + ComboboxSelect, + ComboboxSetText, + ControlGetFocus, + ControlLoseFocus, + DropdownClose, + DropdownOpen, + DropdownPreOpen, + DropdownSelect, + EditCaretChanged, + EditModify, + EditSelectionChanged, + ExtTextInput, + EndExtTextInput, + ItemCollapsed, + ItemExpanded, + ListboxDoubleClick, + ListboxFocus, + ListboxItemAdded, // pData = itempos + ListboxItemRemoved, // pData = itempos, -1=All + ListboxScrolled, + ListboxSelect, + ListboxTreeFocus, + ListboxTreeSelect, + MenuActivate, + MenuDeactivate, + MenuDehighlight, + MenuDisable, + MenuEnable, + MenuHide, + MenuHighlight, + MenuInsertItem, + MenuItemChecked, + MenuItemTextChanged, + MenuItemUnchecked, + MenuRemoveItem, + MenuSelect, + MenuShow, + MenuSubmenuActivate, + MenuSubmenuChanged, + MenuSubmenuDeactivate, + ObjectDying, + PushbuttonToggle, + RadiobuttonToggle, + RoadmapItemSelected, + ScrollbarEndScroll, + ScrollbarScroll, + SpinbuttonDown, + SpinbuttonUp, + SpinfieldDown, + SpinfieldFirst, + SpinfieldLast, + SpinfieldUp, + StatusbarAllItemsRemoved, + StatusbarDrawItem, // pData = itemid + StatusbarHideItem, // pData = itemid + StatusbarItemAdded, // pData = itemid + StatusbarItemRemoved, // pData = itemid + StatusbarNameChanged, // pData = itemid + StatusbarShowItem, // pData = itemid + TabbarPageActivated, // pData = pageid + TabbarPageDeactivated, // pData = pageid + TabbarPageInserted, // pData = pageid + TabbarPageMoved, // pData = Pair( pagepos_old, pagepos_new ) + TabbarPageRemoved, // pData = pageid + TabbarPageSelected, // pData = pageid + TabbarPageTextChanged, // pData = pageid + TableRowSelect, + TabpageActivate, // pData = pageid + TabpageDeactivate, // pData = pageid + TabpageInserted, // pData = pageid + TabpagePageTextChanged, // pData = pageid + TabpageRemoved, // pData = pageid + TabpageRemovedAll, + ToolboxActivate, + ToolboxAllItemsChanged, + ToolboxButtonStateChanged, // pData = itempos + ToolboxClick, + ToolboxDeactivate, + ToolboxDoubleClick, + ToolboxFormatChanged, // request new layout + ToolboxHighlight, + ToolboxHighlightOff, // pData = itempos + ToolboxItemAdded, // pData = itempos + ToolboxItemDisabled, // pData = itempos + ToolboxItemEnabled, // pData = itempos + ToolboxItemRemoved, // pData = itempos + ToolboxItemTextChanged, // pData = itempos + ToolboxItemUpdated, + ToolboxItemWindowChanged, + ToolboxSelect, + WindowActivate, + WindowChildDestroyed, // pData = vcl::Window* + WindowClose, + WindowCommand, // pData = CommandEvent* + WindowDataChanged, // pData = DataChangedEvent* + WindowDeactivate, // pData = vcl::Window* = pPrevActiveWindow + WindowDisabled, + WindowDocking, + WindowEnabled, + WindowEndDocking, // pData = EndDockingData + WindowEndPopupMode, // pData = EndPopupModeData + WindowFrameTitleChanged,// pData = OUString* = oldTitle + WindowGetFocus, + WindowHide, + WindowKeyInput, // pData = KeyEvent* + WindowKeyUp, // pData = KeyEvent* + WindowLoseFocus, + WindowMenubarAdded, // pData = pMenuBar + WindowMenubarRemoved, // pData = pMenuBar + WindowMinimize, + WindowMouseButtonDown, // pData = MouseEvent* + WindowMouseButtonUp, // pData = MouseEvent* + WindowMouseMove, // pData = MouseEvent* + WindowMove, + WindowNormalize, + WindowPaint, // pData = Rectangle* + WindowPrepareToggleFloating, // pData = bool + WindowResize, + WindowShow, + WindowStartDocking, // pData = DockingData + WindowToggleFloating, + WindowGestureEvent, +}; + +class VCL_DLLPUBLIC VclSimpleEvent +{ +private: + VclEventId nId; + + VclSimpleEvent(VclSimpleEvent const &) = delete; + VclSimpleEvent& operator =(VclSimpleEvent const &) = delete; + +public: + VclSimpleEvent( VclEventId n ) { nId = n; } + virtual ~VclSimpleEvent() {} + + VclEventId GetId() const { return nId; } +}; + +class VCL_DLLPUBLIC VclWindowEvent final : public VclSimpleEvent +{ +private: + VclPtr<vcl::Window> pWindow; + void* pData; + +public: + VclWindowEvent( vcl::Window* pWin, VclEventId n, void* pDat ); + virtual ~VclWindowEvent() override; + + vcl::Window* GetWindow() const { return pWindow; } + void* GetData() const { return pData; } +}; + +class VCL_DLLPUBLIC VclMenuEvent final : public VclSimpleEvent +{ +private: + VclPtr<Menu> pMenu; + sal_uInt16 mnPos; + + VclMenuEvent(VclMenuEvent const &) = delete; + VclMenuEvent& operator =(VclMenuEvent const &) = delete; + +public: + VclMenuEvent( Menu* pM, VclEventId n, sal_uInt16 nPos ); + virtual ~VclMenuEvent() override; + + Menu* GetMenu() const; + sal_uInt16 GetItemPos() const { return mnPos; } +}; + +class VCL_DLLPUBLIC VclAccessibleEvent final : public VclSimpleEvent +{ +public: + VclAccessibleEvent( VclEventId n, const css::uno::Reference< css::accessibility::XAccessible >& rxAccessible ); + virtual ~VclAccessibleEvent() override; + const css::uno::Reference< css::accessibility::XAccessible >& GetAccessible() const { return mxAccessible;} + +private: + css::uno::Reference< css::accessibility::XAccessible > mxAccessible; +}; + +#endif // INCLUDED_VCL_VCLEVENT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx new file mode 100644 index 000000000..99884011e --- /dev/null +++ b/include/vcl/vcllayout.hxx @@ -0,0 +1,120 @@ +/* -*- 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_VCLLAYOUT_HXX +#define INCLUDED_VCL_VCLLAYOUT_HXX + +#include <basegfx/polygon/b2dpolypolygon.hxx> +#include <tools/gen.hxx> +#include <vcl/devicecoordinate.hxx> +#include <vcl/dllapi.h> + +class ImplLayoutArgs; +class PhysicalFontFace; +class SalGraphics; +class GlyphItem; +class SalLayoutGlyphs; + +// all positions/widths are in font units +// one exception: drawposition is in pixel units + +// Unfortunately there is little documentation to help implementors of +// new classes derived from SalLayout ("layout engines"), and the code +// and data structures are far from obvious. + +// For instance, I *think* the important virtual functions in the +// layout engines are called in this order: + +// * InitFont() +// * LayoutText() +// * AdjustLayout(), any number of times (but presumably +// usually not at all or just once) +// * Optionally, DrawText() + +// Functions that just return information like GetTexWidth() and +// FillDXArray() are called after LayoutText() and before DrawText(). + +// Another important questions is which parts of an ImplLayoutArgs can +// be changed by callers between LayoutText() and AdjustLayout() +// calls. It probably makes sense only if one assumes that the "string +// related inputs" part are not changed after LayoutText(). + +// But why use the same ImplLayoutArgs structure as parameter for both +// LayoutText() and AdjustLayout() in the first place? And why +// duplicate some of the fields in both SalLayout and ImplLayoutArgs +// (mnMinCharPos, mnEndCharPos, mnLayoutFlags==mnFlags, +// mnOrientation)? Lost in history... + +class VCL_DLLPUBLIC SalLayout +{ +public: + virtual ~SalLayout(); + // used by upper layers + Point& DrawBase() { return maDrawBase; } + const Point& DrawBase() const { return maDrawBase; } + Point& DrawOffset() { return maDrawOffset; } + const Point& DrawOffset() const { return maDrawOffset; } + Point GetDrawPosition( const Point& rRelative = Point(0,0) ) const; + + virtual bool LayoutText( ImplLayoutArgs&, const SalLayoutGlyphs* ) = 0; // first step of layouting + virtual void AdjustLayout( ImplLayoutArgs& ); // adjusting after fallback etc. + virtual void InitFont() const {} + virtual void DrawText( SalGraphics& ) const = 0; + + int GetUnitsPerPixel() const { return mnUnitsPerPixel; } + int GetOrientation() const { return mnOrientation; } + + // methods using string indexing + virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const = 0; + virtual DeviceCoordinate FillDXArray( DeviceCoordinate* pDXArray ) const = 0; + virtual DeviceCoordinate GetTextWidth() const { return FillDXArray( nullptr ); } + virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const = 0; + virtual bool IsKashidaPosValid ( int /*nCharPos*/ ) const { return true; } // i60594 + + // methods using glyph indexing + virtual bool GetNextGlyph(const GlyphItem** pGlyph, Point& rPos, int& nStart, + const PhysicalFontFace** pFallbackFont = nullptr, + int* const pFallbackLevel = nullptr) const = 0; + virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const; + bool GetBoundRect(tools::Rectangle&) const; + + virtual const SalLayoutGlyphs* GetGlyphs() const; + +protected: + // used by layout engines + SalLayout(); + +private: + SalLayout(const SalLayout&) = delete; + SalLayout& operator=(const SalLayout&) = delete; + +protected: + int mnMinCharPos; + int mnEndCharPos; + + int mnUnitsPerPixel; + int mnOrientation; + + mutable Point maDrawOffset; + Point maDrawBase; +}; + +#endif // INCLUDED_VCL_VCLLAYOUT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclmain.hxx b/include/vcl/vclmain.hxx new file mode 100644 index 000000000..54a630c43 --- /dev/null +++ b/include/vcl/vclmain.hxx @@ -0,0 +1,33 @@ +/* -*- 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_VCLMAIN_HXX +#define INCLUDED_VCL_VCLMAIN_HXX + +#include <sal/config.h> + +#ifdef DBG_UTIL +#include <vcl/dllapi.h> +#endif + +namespace vclmain { + +// Function called from vclmain's implementation of main, needs to be +// implemented by the application and needs to instantiate a (static, derived) +// instance of Application (where the Application constructor takes care to link +// that instance to ImplSVData.mpApp): +void createApplication(); +#ifdef DBG_UTIL +VCL_DLLPUBLIC bool isAlive(); +#endif +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclmedit.hxx b/include/vcl/vclmedit.hxx new file mode 100644 index 000000000..307d218a5 --- /dev/null +++ b/include/vcl/vclmedit.hxx @@ -0,0 +1,178 @@ +/* -*- 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_VCLMEDIT_HXX +#define INCLUDED_VCL_VCLMEDIT_HXX + +#include <tools/lineend.hxx> +#include <tools/wintypes.hxx> +#include <vcl/edit.hxx> +#include <vcl/dllapi.h> +#include <vcl/timer.hxx> +#include <memory> + +class ImpVclMEdit; +class ExtTextEngine; +class TextView; + +class TextWindow final : public vcl::Window +{ +private: + VclPtr<Edit> mxParent; + std::unique_ptr<ExtTextEngine> mpExtTextEngine; + std::unique_ptr<TextView> mpExtTextView; + + bool mbInMBDown; + bool mbFocusSelectionHide; + bool mbIgnoreTab; + bool mbActivePopup; + bool mbSelectOnTab; + +public: + explicit TextWindow(Edit* pParent); + virtual ~TextWindow() override; + virtual void dispose() override; + + ExtTextEngine* GetTextEngine() const { return mpExtTextEngine.get(); } + TextView* GetTextView() const { return mpExtTextView.get(); } + + virtual void MouseMove( const MouseEvent& rMEvt ) override; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void KeyInput( const KeyEvent& rKEvent ) override; + + virtual void Command( const CommandEvent& rCEvt ) override; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; + + virtual void GetFocus() override; + virtual void LoseFocus() override; + + void SetAutoFocusHide( bool bAutoHide ) { mbFocusSelectionHide = bAutoHide; } + + void SetIgnoreTab( bool bIgnore ) { mbIgnoreTab = bIgnore; } + + void DisableSelectionOnFocus() { mbSelectOnTab = false; } +}; + +class VCL_DLLPUBLIC VclMultiLineEdit : public Edit +{ + friend class VCLXAccessibleEdit; + +private: + std::unique_ptr<ImpVclMEdit> pImpVclMEdit; + + Link<Edit&,void> aModifyHdlLink; + + std::unique_ptr<Timer> pUpdateDataTimer; + +protected: + + DECL_LINK( ImpUpdateDataHdl, Timer*, void ); + void StateChanged( StateChangedType nType ) override; + void DataChanged( const DataChangedEvent& rDCEvt ) override; + virtual bool PreNotify( NotifyEvent& rNEvt ) override; + virtual bool EventNotify( NotifyEvent& rNEvt ) override; + using Control::ImplInitSettings; + void ImplInitSettings( bool bBackground ); + static WinBits ImplInitStyle( WinBits nStyle ); + + TextView* GetTextView() const; + ExtTextEngine* GetTextEngine() const; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext) override; +public: + VclMultiLineEdit( vcl::Window* pParent, + WinBits nWinStyle ); + virtual ~VclMultiLineEdit() override; + virtual void dispose() override; + + void SelectionChanged(); + void CaretChanged(); + virtual void Modify() override; + + virtual void SetModifyFlag() override; + virtual void ClearModifyFlag() override; + virtual bool IsModified() const override; + + void EnableUpdateData( sal_uLong nTimeout ); + virtual void UpdateData(); + void DisableUpdateData() { pUpdateDataTimer.reset(); } + + virtual void SetReadOnly( bool bReadOnly = true ) override; + virtual bool IsReadOnly() const override; + + void EnableFocusSelectionHide( bool bHide ); + + virtual void SetMaxTextLen(sal_Int32 nMaxLen) override; + virtual sal_Int32 GetMaxTextLen() const override; + + void SetMaxTextWidth(long nMaxWidth); + + virtual void SetSelection( const Selection& rSelection ) override; + virtual const Selection& GetSelection() const override; + + virtual void ReplaceSelected( const OUString& rStr ) override; + virtual void DeleteSelected() override; + virtual OUString GetSelected() const override; + OUString GetSelected( LineEnd aSeparator ) const; + + virtual void Cut() override; + virtual void Copy() override; + virtual void Paste() override; + + virtual void SetText( const OUString& rStr ) override; + virtual void SetText( const OUString& rStr, const Selection& rNewSelection ) override + { SetText( rStr ); SetSelection( rNewSelection ); } + OUString GetText() const override; + OUString GetText( LineEnd aSeparator ) const; + OUString GetTextLines( LineEnd aSeparator ) const; + + void SetRightToLeft( bool bRightToLeft ); + + void SetModifyHdl( const Link<Edit&,void>& rLink ) override { aModifyHdlLink = rLink; } + const Link<Edit&,void>& GetModifyHdl() const override { return aModifyHdlLink; } + + virtual void Resize() override; + virtual void GetFocus() override; + + virtual Size CalcMinimumSize() const override; + Size CalcAdjustedSize( const Size& rPrefSize ) const; + Size CalcBlockSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const; + void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const; + + void Draw( OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ) override; + + void DisableSelectionOnFocus(); + + void EnableCursor( bool bEnable ); + + ScrollBar& GetVScrollBar() const; + + TextWindow* GetTextWindow(); + + virtual FactoryFunction GetUITestFactory() const override; + + virtual bool set_property(const OString &rKey, const OUString &rValue) override; +}; + +#endif // INCLUDED_VCL_VCLMEDIT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx new file mode 100644 index 000000000..0910257c4 --- /dev/null +++ b/include/vcl/vclptr.hxx @@ -0,0 +1,442 @@ +/* -*- 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_PTR_HXX +#define INCLUDED_VCL_PTR_HXX + +#include <sal/config.h> + +#include <rtl/ref.hxx> + +#include <utility> +#include <type_traits> + +#ifdef DBG_UTIL +#ifndef _WIN32 +#include <vcl/vclmain.hxx> +#endif +#endif + +class VclReferenceBase; + +namespace vcl::detail { + +template<typename> +constexpr bool isIncompleteOrDerivedFromVclReferenceBase(...) { return true; } + +template<typename T> constexpr bool isIncompleteOrDerivedFromVclReferenceBase( + int (*)[sizeof(T)]) +{ return std::is_base_of<VclReferenceBase, T>::value; } + +} // namespace vcl::detail + +/** + * A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for references to vcl::Window subclasses. + * + * For more details on the design please see vcl/README.lifecycle + * + * @param reference_type must be a subclass of vcl::Window + */ +template <class reference_type> +class VclPtr +{ + static_assert( + vcl::detail::isIncompleteOrDerivedFromVclReferenceBase<reference_type>( + nullptr), + "template argument type must be derived from VclReferenceBase"); + + ::rtl::Reference<reference_type> m_rInnerRef; + +public: + /** Constructor... + */ + VclPtr() + : m_rInnerRef() + {} + + /** Constructor... + */ + VclPtr (reference_type * pBody) + : m_rInnerRef(pBody) + {} + + /** Constructor... that doesn't take a ref. + */ + VclPtr (reference_type * pBody, __sal_NoAcquire) + : m_rInnerRef(pBody, SAL_NO_ACQUIRE) + {} + + /** Up-casting conversion constructor: Copies interface reference. + + Does not work for up-casts to ambiguous bases. For the special case of + up-casting to Reference< XInterface >, see the corresponding conversion + operator. + + @param rRef another reference + */ + template< class derived_type > + VclPtr( + const VclPtr< derived_type > & rRef, + typename std::enable_if< + std::is_base_of<reference_type, derived_type>::value, int>::type + = 0 ) + : m_rInnerRef( static_cast<reference_type*>(rRef) ) + { + } + +#if defined(DBG_UTIL) && !defined(_WIN32) + virtual ~VclPtr() + { + assert(m_rInnerRef.get() == nullptr || vclmain::isAlive()); + // We can be one of the intermediate counts, but if we are the last + // VclPtr keeping this object alive, then something forgot to call dispose(). + assert((!m_rInnerRef.get() || m_rInnerRef->isDisposed() || m_rInnerRef->getRefCount() > 1) + && "someone forgot to call dispose()"); + } + VclPtr(VclPtr const &) = default; + VclPtr(VclPtr &&) = default; + VclPtr & operator =(VclPtr const &) = default; + VclPtr & operator =(VclPtr &&) = default; +#endif + + /** + * A construction helper for VclPtr. Since VclPtr types are created + * with a reference-count of one - to help fit into the existing + * code-flow; this helps us to construct them easily. + * + * For more details on the design please see vcl/README.lifecycle + * + * @tparam reference_type must be a subclass of vcl::Window + */ + template<typename... Arg> [[nodiscard]] static VclPtr< reference_type > Create(Arg &&... arg) + { + return VclPtr< reference_type >( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ); + } + + /** Probably most common used: handle->someBodyOp(). + */ + reference_type * operator->() const + { + return m_rInnerRef.get(); + } + + /** Get the body. Can be used instead of operator->(). + I.e. handle->someBodyOp() and handle.get()->someBodyOp() + are the same. + */ + reference_type * get() const + { + return m_rInnerRef.get(); + } + + void set(reference_type *pBody) + { + m_rInnerRef.set(pBody); + } + + void reset(reference_type *pBody) + { + m_rInnerRef.set(pBody); + } + + /** Up-casting copy assignment operator. + + Does not work for up-casts to ambiguous bases. + + @param rRef another reference + */ + template<typename derived_type> + typename std::enable_if< + std::is_base_of<reference_type, derived_type>::value, + VclPtr &>::type + operator =(VclPtr<derived_type> const & rRef) + { + m_rInnerRef.set(rRef.get()); + return *this; + } + + VclPtr & operator =(reference_type * pBody) + { + m_rInnerRef.set(pBody); + return *this; + } + + operator reference_type * () const + { + return m_rInnerRef.get(); + } + + explicit operator bool () const + { + return m_rInnerRef.get() != nullptr; + } + + void clear() + { + m_rInnerRef.clear(); + } + + void reset() + { + m_rInnerRef.clear(); + } + + void disposeAndClear() + { + // hold it alive for the lifetime of this method + ::rtl::Reference<reference_type> aTmp(m_rInnerRef); + m_rInnerRef.clear(); // we should use some 'swap' method ideally ;-) + if (aTmp.get()) { + aTmp->disposeOnce(); + } + } + + /** Needed to place VclPtr's into STL collection. + */ + bool operator< (const VclPtr<reference_type> & handle) const + { + return (m_rInnerRef < handle.m_rInnerRef); + } +}; // class VclPtr + +template<typename T1, typename T2> +inline bool operator ==(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { + return p1.get() == p2.get(); +} + +template<typename T> inline bool operator ==(VclPtr<T> const & p1, T const * p2) +{ + return p1.get() == p2; +} + +template<typename T> inline bool operator ==(VclPtr<T> const & p1, T * p2) { + return p1.get() == p2; +} + +template<typename T> inline bool operator ==(T const * p1, VclPtr<T> const & p2) +{ + return p1 == p2.get(); +} + +template<typename T> inline bool operator ==(T * p1, VclPtr<T> const & p2) { + return p1 == p2.get(); +} + +template<typename T1, typename T2> +inline bool operator !=(VclPtr<T1> const & p1, VclPtr<T2> const & p2) { + return !(p1 == p2); +} + +template<typename T> inline bool operator !=(VclPtr<T> const & p1, T const * p2) +{ + return !(p1 == p2); +} + +template<typename T> inline bool operator !=(VclPtr<T> const & p1, T * p2) { + return !(p1 == p2); +} + +template<typename T> inline bool operator !=(T const * p1, VclPtr<T> const & p2) +{ + return !(p1 == p2); +} + +template<typename T> inline bool operator !=(T * p1, VclPtr<T> const & p2) { + return !(p1 == p2); +} + +/** + * A construction helper for a temporary VclPtr. Since VclPtr types + * are created with a reference-count of one - to help fit into + * the existing code-flow; this helps us to construct them easily. + * see also VclPtr::Create and ScopedVclPtr + * + * For more details on the design please see vcl/README.lifecycle + * + * @param reference_type must be a subclass of vcl::Window + */ +template <class reference_type> +class SAL_WARN_UNUSED VclPtrInstance final : public VclPtr<reference_type> +{ +public: + template<typename... Arg> VclPtrInstance(Arg &&... arg) + : VclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) + { + } + + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static VclPtrInstance< reference_type > Create(Arg &&... ) = delete; +}; + +template <class reference_type> +class ScopedVclPtr : public VclPtr<reference_type> +{ +public: + /** Constructor... + */ + ScopedVclPtr() + : VclPtr<reference_type>() + {} + + /** Constructor + */ + ScopedVclPtr (reference_type * pBody) + : VclPtr<reference_type>(pBody) + {} + + /** Copy constructor... + */ + ScopedVclPtr (const VclPtr<reference_type> & handle) + : VclPtr<reference_type>(handle) + {} + + /** + Assignment that releases the last reference. + */ + void disposeAndReset(reference_type *pBody) + { + if (pBody != this->get()) { + VclPtr<reference_type>::disposeAndClear(); + VclPtr<reference_type>::set(pBody); + } + } + + /** + Assignment that releases the last reference. + */ + ScopedVclPtr<reference_type>& operator = (reference_type * pBody) + { + disposeAndReset(pBody); + return *this; + } + + /** Up-casting conversion constructor: Copies interface reference. + + Does not work for up-casts to ambiguous bases. For the special case of + up-casting to Reference< XInterface >, see the corresponding conversion + operator. + + @param rRef another reference + */ + template< class derived_type > + ScopedVclPtr( + const VclPtr< derived_type > & rRef, + typename std::enable_if< + std::is_base_of<reference_type, derived_type>::value, int>::type + = 0 ) + : VclPtr<reference_type>( rRef ) + { + } + + /** Up-casting assignment operator. + + Does not work for up-casts to ambiguous bases. + + @param rRef another VclPtr + */ + template<typename derived_type> + typename std::enable_if< + std::is_base_of<reference_type, derived_type>::value, + ScopedVclPtr &>::type + operator =(VclPtr<derived_type> const & rRef) + { + disposeAndReset(rRef.get()); + return *this; + } + + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static ScopedVclPtr< reference_type > Create(Arg &&... ) = delete; + + ~ScopedVclPtr() + { + VclPtr<reference_type>::disposeAndClear(); + assert(VclPtr<reference_type>::get() == nullptr); // make sure there are no lingering references + } + +private: + // Most likely we don't want this default copy-constructor. + ScopedVclPtr (const ScopedVclPtr<reference_type> &) = delete; + // And certainly we don't want a default assignment operator. + ScopedVclPtr<reference_type>& operator = (const ScopedVclPtr<reference_type> &) = delete; + // And disallow reset as that doesn't call disposeAndClear on the original reference + void reset() = delete; + void reset(reference_type *pBody) = delete; + +protected: + ScopedVclPtr (reference_type * pBody, __sal_NoAcquire) + : VclPtr<reference_type>(pBody, SAL_NO_ACQUIRE) + {} +}; + +/** + * A construction helper for ScopedVclPtr. Since VclPtr types are created + * with a reference-count of one - to help fit into the existing + * code-flow; this helps us to construct them easily. + * + * For more details on the design please see vcl/README.lifecycle + * + * @param reference_type must be a subclass of vcl::Window + */ +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4521) // " multiple copy constructors specified" +#endif +template <class reference_type> +class SAL_WARN_UNUSED ScopedVclPtrInstance final : public ScopedVclPtr<reference_type> +{ +public: + template<typename... Arg> ScopedVclPtrInstance(Arg &&... arg) + : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) + { + } + + /** + * Override and disallow this, to prevent people accidentally calling it and actually + * getting VclPtr::Create and getting a naked VclPtr<> instance + */ + template<typename... Arg> static ScopedVclPtrInstance< reference_type > Create(Arg &&...) = delete; + +private: + // Prevent the above perfect forwarding ctor from hijacking (accidental) + // attempts at ScopedVclPtrInstance copy construction (where the hijacking + // would typically lead to somewhat obscure error messages); both non-const + // and const variants are needed here, as the ScopedVclPtr base class has a + // const--variant copy ctor, so the implicitly declared copy ctor for + // ScopedVclPtrInstance would also be the const variant, so non-const copy + // construction attempts would be hijacked by the perfect forwarding ctor; + // but if we only declared a non-const variant here, the const variant would + // no longer be implicitly declared (as there would already be an explicitly + // declared copy ctor), so const copy construction attempts would then be + // hijacked by the perfect forwarding ctor: + ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete; + ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete; +}; +#if defined _MSC_VER +#pragma warning(pop) +#endif + +#endif // INCLUDED_VCL_PTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/vclreferencebase.hxx b/include/vcl/vclreferencebase.hxx new file mode 100644 index 000000000..b7dc2b918 --- /dev/null +++ b/include/vcl/vclreferencebase.hxx @@ -0,0 +1,68 @@ +/* -*- 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_Reference_HXX +#define INCLUDED_VCL_Reference_HXX + +#include <vcl/dllapi.h> +#include <osl/interlck.h> + +class VCL_DLLPUBLIC VclReferenceBase +{ + mutable oslInterlockedCount mnRefCnt; + + template<typename T> friend class VclPtr; + +public: + void acquire() const + { + osl_atomic_increment(&mnRefCnt); + } + + void release() const + { + if (osl_atomic_decrement(&mnRefCnt) == 0) + delete this; + } +#ifdef DBG_UTIL +#ifndef _WIN32 + sal_Int32 getRefCount() const { return mnRefCnt; } +#endif +#endif + + +private: + VclReferenceBase(const VclReferenceBase&) = delete; + VclReferenceBase& operator=(const VclReferenceBase&) = delete; + + bool mbDisposed : 1; + +protected: + VclReferenceBase(); +protected: + virtual ~VclReferenceBase(); + +protected: + virtual void dispose(); + +public: + void disposeOnce(); + bool isDisposed() const { return mbDisposed; } + +}; +#endif diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx new file mode 100644 index 000000000..041c59e83 --- /dev/null +++ b/include/vcl/vectorgraphicdata.hxx @@ -0,0 +1,131 @@ +/* -*- 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_VECTORGRAPHICDATA_HXX +#define INCLUDED_VCL_VECTORGRAPHICDATA_HXX + +#include <basegfx/range/b2drange.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <vcl/bitmapex.hxx> +#include <rtl/ustring.hxx> +#include <deque> +#include <memory> +#include <algorithm> + +namespace com::sun::star::graphic { class XPrimitive2D; } +struct WmfExternal; + +typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray; + + +// helper to convert any Primitive2DSequence to a good quality BitmapEx, +// using default parameters and graphic::XPrimitive2DRenderer + +BitmapEx VCL_DLLPUBLIC convertPrimitive2DSequenceToBitmapEx( + const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& rSequence, + const basegfx::B2DRange& rTargetRange, + const sal_uInt32 nMaximumQuadraticPixels = 500000); + + +enum class VectorGraphicDataType +{ + Svg = 0, + Emf = 1, + Wmf = 2, + Pdf = 3 +}; + +class VCL_DLLPUBLIC VectorGraphicData +{ +private: + // the file and length + VectorGraphicDataArray maVectorGraphicDataArray; + + // The absolute Path if available + OUString maPath; + + // on demand created content + bool mbSequenceCreated; + basegfx::B2DRange maRange; + std::deque< css::uno::Reference< css::graphic::XPrimitive2D > > maSequence; + BitmapEx maReplacement; + size_t mNestedBitmapSize; + VectorGraphicDataType meVectorGraphicDataType; + + // extra: + std::unique_ptr<WmfExternal> mpExternalHeader; + + // If the vector format has more pages this denotes which page to render + sal_Int32 mnPageIndex; + + /// Useful for PDF, which is vector-based, but still rendered to a bitmap. + basegfx::B2DTuple maSizeHint; + + // on demand creators + void ensurePdfReplacement(); + void ensureReplacement(); + void ensureSequenceAndRange(); + + VectorGraphicData(const VectorGraphicData&) = delete; + VectorGraphicData& operator=(const VectorGraphicData&) = delete; + +public: + VectorGraphicData( + const VectorGraphicDataArray& rVectorGraphicDataArray, + const OUString& rPath, + VectorGraphicDataType eVectorDataType, + sal_Int32 nPageIndex = -1); + VectorGraphicData(const OUString& rPath, VectorGraphicDataType eVectorDataType); + ~VectorGraphicData(); + + /// compare op + bool operator==(const VectorGraphicData& rCandidate) const; + + /// special: needed for emf/wmf, maybe replaced by scaling the result later (?) + void setWmfExternalHeader(const WmfExternal& aExtHeader); + + /// data read + const VectorGraphicDataArray& getVectorGraphicDataArray() const { return maVectorGraphicDataArray; } + sal_uInt32 getVectorGraphicDataArrayLength() const { return maVectorGraphicDataArray.getLength(); } + enum class State { UNPARSED, PARSED }; + std::pair<State, size_t> getSizeBytes() const; + const OUString& getPath() const { return maPath; } + const VectorGraphicDataType& getVectorGraphicDataType() const { return meVectorGraphicDataType; } + + /// data read and evtl. on demand creation + const basegfx::B2DRange& getRange() const; + const std::deque< css::uno::Reference< css::graphic::XPrimitive2D > >& getPrimitive2DSequence() const; + const BitmapEx& getReplacement() const; + BitmapChecksum GetChecksum() const; + + sal_Int32 getPageIndex() const { return std::max(sal_Int32(0), mnPageIndex); } + + void setSizeHint(const basegfx::B2DTuple& rSizeHint) + { + maSizeHint = rSizeHint; + } + + const basegfx::B2DTuple& getSizeHint() const { return maSizeHint; } + + bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; } +}; + +#endif // INCLUDED_VCL_VECTORGRAPHICDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/viewdataentry.hxx b/include/vcl/viewdataentry.hxx new file mode 100644 index 000000000..2bce7556a --- /dev/null +++ b/include/vcl/viewdataentry.hxx @@ -0,0 +1,87 @@ +/* -*- 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 <vcl/dllapi.h> +#include <tools/solar.h> +#include <tools/gen.hxx> + +#include <vector> + +class SvTreeListBox; + +struct SvViewDataItem +{ + int mnWidth = 0; + int mnHeight = 0; +}; + +/** + * 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<SvViewDataItem> maItems; + sal_uLong nVisPos; + bool mbSelected:1; + bool mbHighlighted:1; + bool mbExpanded:1; + bool mbFocused:1; + bool mbSelectable:1; + bool mbDragTarget:1; + +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;} + bool IsDragTarget() const { return mbDragTarget;} + void SetFocus( bool bFocus ); + void SetSelected( bool bSelected ); + void SetExpanded( bool bExpanded ); + void SetSelectable( bool bSelectable ); + void SetDragTarget( bool bDragTarget ) + { + mbDragTarget = bDragTarget; + } + + void Init(size_t nSize); + + const SvViewDataItem& GetItem(size_t nPos) const; + SvViewDataItem& GetItem(size_t nPos); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx new file mode 100644 index 000000000..0268e49a1 --- /dev/null +++ b/include/vcl/virdev.hxx @@ -0,0 +1,194 @@ +/* -*- 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_VIRDEV_HXX +#define INCLUDED_VCL_VIRDEV_HXX + +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <vcl/salgtype.hxx> +#include <memory> + +class SalVirtualDevice; +struct SystemGraphicsData; +typedef struct _cairo_surface cairo_surface_t; + +class SAL_WARN_UNUSED VCL_DLLPUBLIC VirtualDevice : public OutputDevice +{ + friend class Application; + friend class ::OutputDevice; + friend class Printer; + friend cairo_surface_t* get_underlying_cairo_surface(const VirtualDevice&); +public: + // reference device modes for different compatibility levels + enum class RefDevMode { NONE = 0, + Dpi600 = 1, // 600 dpi + MSO1 = 3, + PDF1 = 4, + Custom = 5 + }; + +private: + std::unique_ptr<SalVirtualDevice> mpVirDev; + VclPtr<VirtualDevice> mpPrev; + VclPtr<VirtualDevice> mpNext; + sal_uInt16 mnBitCount; + bool mbScreenComp; + const DeviceFormat meFormat; + const DeviceFormat meAlphaFormat; + RefDevMode meRefDevMode; + bool mbForceZeroExtleadBug; + + SAL_DLLPRIVATE void ImplInitVirDev( const OutputDevice* pOutDev, long nDX, long nDY, const SystemGraphicsData *pData = nullptr ); + SAL_DLLPRIVATE bool InnerImplSetOutputSizePixel( const Size& rNewSize, bool bErase, + sal_uInt8* pBuffer ); + SAL_DLLPRIVATE bool ImplSetOutputSizePixel( const Size& rNewSize, bool bErase, + sal_uInt8* pBuffer ); + + VirtualDevice (const VirtualDevice &) = delete; + VirtualDevice & operator= (const VirtualDevice &) = delete; + + /** Used for alpha VDev, to set areas to opaque + + @since \#i32109# + */ + SAL_DLLPRIVATE void ImplFillOpaqueRectangle( const tools::Rectangle& rRect ); + +protected: + virtual bool AcquireGraphics() const override; + virtual void ReleaseGraphics( bool bRelease = true ) override; + + /** Create a virtual device of size 1x1 + + @param pCompDev + The generated vdev will be compatible to this device. + If it's the nullptr, it uses Application::GetDefaultDevice(). + + @param eFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + + @param eAlphaFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + + @param eOutDevType + This real virtual output device type. + */ + explicit VirtualDevice(const OutputDevice* pCompDev, DeviceFormat eFormat, + DeviceFormat eAlphaFormat, OutDevType eOutDevType); + +public: + + /** Create a virtual device of size 1x1 + + @param eFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + + @param eAlphaFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + */ + explicit VirtualDevice(DeviceFormat eFormat = DeviceFormat::DEFAULT, DeviceFormat eAlphaFormat = DeviceFormat::NONE) + : VirtualDevice(nullptr, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {} + + /** Create a virtual device of size 1x1 + + @param rCompDev + The generated vdev will be compatible to this device. + + @param eFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + */ + explicit VirtualDevice(const OutputDevice& rCompDev, + DeviceFormat eFormat = DeviceFormat::DEFAULT) + : VirtualDevice(&rCompDev, eFormat, DeviceFormat::NONE, OUTDEV_VIRDEV) {} + + /** Create a virtual device of size 1x1 with alpha channel + + @param rCompDev + The generated vdev will be compatible to this device. + + @param eFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + + @param eAlphaFormat + Device format of the generated virtual device. Use DeviceFormat::DEFAULT here, to + indicate: take default screen depth. Only DeviceFormat::BITMASK + is the other possibility to denote a binary mask. + */ + explicit VirtualDevice(const OutputDevice& rCompDev, + DeviceFormat eFormat, DeviceFormat eAlphaFormat) + : VirtualDevice(&rCompDev, eFormat, eAlphaFormat, OUTDEV_VIRDEV) {} + + /** Create a virtual device using an existing system dependent device or graphics context + Any rendering will happen directly on the context and not on any intermediate bitmap. + Note: This might not be supported on all platforms ! + */ + explicit VirtualDevice(const SystemGraphicsData& rData, const Size &rSize, + DeviceFormat eFormat); + + virtual ~VirtualDevice() override; + virtual void dispose() override; + + virtual void EnableRTL( bool bEnable = true ) override; + + bool SetOutputSizePixel( const Size& rNewSize, bool bErase = true ); + bool SetOutputSizePixelScaleOffsetAndBuffer( const Size& rNewSize, + const Fraction& rScale, + const Point& rNewOffset, + sal_uInt8* pBuffer); + + bool SetOutputSize( const Size& rNewSize ) + { return SetOutputSizePixel( LogicToPixel( rNewSize ) ); } + + void SetReferenceDevice( RefDevMode ); + + void Compat_ZeroExtleadBug(); // enable workaround for #i60495# + + void SetReferenceDevice( sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ); + + virtual sal_uInt16 GetBitCount() const override; + + bool IsVirtual() const override; + + bool IsScreenComp() const override { return mbScreenComp; } + +private: + SAL_DLLPRIVATE void ImplSetReferenceDevice( RefDevMode, sal_Int32 i_nDPIX, sal_Int32 i_nDPIY ); + +protected: + virtual bool UsePolyPolygonForComplexGradient() override; + + virtual long GetFontExtLeading() const override; + +}; + +#endif // INCLUDED_VCL_VIRDEV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/waitobj.hxx b/include/vcl/waitobj.hxx new file mode 100644 index 000000000..682153a1e --- /dev/null +++ b/include/vcl/waitobj.hxx @@ -0,0 +1,59 @@ +/* -*- 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_WAITOBJ_HXX +#define INCLUDED_VCL_WAITOBJ_HXX + +#include <vcl/dllapi.h> +#include <vcl/window.hxx> + +#include <stack> +#include <vector> + +namespace weld { class Widget; } + +class VCL_DLLPUBLIC WaitObject +{ +private: + VclPtr<vcl::Window> mpWindow; +public: + WaitObject( vcl::Window* pWindow ) + { + mpWindow = pWindow; + if ( mpWindow ) + mpWindow->EnterWait(); + } + ~WaitObject(); +}; + +class VCL_DLLPUBLIC TopLevelWindowLocker +{ +private: + std::stack<std::vector<VclPtr<vcl::Window>>> m_aBusyStack; +public: + // lock all toplevels, except the argument + void incBusy(const weld::Widget* pIgnore); + // unlock previous lock + void decBusy(); + bool isBusy() const { return !m_aBusyStack.empty(); } +}; + +#endif // INCLUDED_VCL_WAITOBJ_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wall.hxx b/include/vcl/wall.hxx new file mode 100644 index 000000000..3aa0949b9 --- /dev/null +++ b/include/vcl/wall.hxx @@ -0,0 +1,113 @@ +/* -*- 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_WALL_HXX +#define INCLUDED_VCL_WALL_HXX + +#include <tools/color.hxx> +#include <tools/gen.hxx> +#include <vcl/dllapi.h> +#include <o3tl/cow_wrapper.hxx> + +class Gradient; +class BitmapEx; +class ImplWallpaper; + +enum class WallpaperStyle +{ + NONE, + Tile, + Center, + Scale, + TopLeft, + Top, + TopRight, + Left, + Right, + BottomLeft, + Bottom, + BottomRight, + ApplicationGradient // defines a gradient that internally covers the whole application + // and uses a color derived from the face color +}; + +class VCL_DLLPUBLIC Wallpaper +{ +public: + typedef o3tl::cow_wrapper<ImplWallpaper> ImplType; + + SAL_DLLPRIVATE void ImplSetCachedBitmap( BitmapEx& rBmp ) const; + SAL_DLLPRIVATE const BitmapEx* ImplGetCachedBitmap() const; + SAL_DLLPRIVATE void ImplReleaseCachedBitmap() const; + +private: + ImplType mpImplWallpaper; + + SAL_DLLPRIVATE static Gradient ImplGetApplicationGradient(); + +public: + Wallpaper(); + Wallpaper( const Wallpaper& rWallpaper ); + Wallpaper( Wallpaper&& rWallpaper ); + Wallpaper( const Color& rColor ); + explicit Wallpaper( const BitmapEx& rBmpEx ); + Wallpaper( const Gradient& rGradient ); + ~Wallpaper(); + + void SetColor( const Color& rColor ); + const Color& GetColor() const; + + void SetStyle( WallpaperStyle eStyle ); + WallpaperStyle GetStyle() const; + + void SetBitmap( const BitmapEx& rBitmap ); + BitmapEx GetBitmap() const; + bool IsBitmap() const; + + void SetGradient( const Gradient& rGradient ); + Gradient GetGradient() const; + bool IsGradient() const; + + void SetRect( const tools::Rectangle& rRect ); + tools::Rectangle GetRect() const; + bool IsRect() const; + + bool IsFixed() const; + bool IsScrollable() const; + + Wallpaper& operator=( const Wallpaper& rWallpaper ); + Wallpaper& operator=( Wallpaper&& rWallpaper ); + + bool operator==( const Wallpaper& rWallpaper ) const; + bool operator!=( const Wallpaper& rWallpaper ) const + { return !(Wallpaper::operator==( rWallpaper )); } + + bool IsEmpty() const + { + return GetStyle() == WallpaperStyle::NONE && GetColor() == COL_TRANSPARENT && + !IsBitmap() && !IsGradient() && !IsRect(); + } + + friend SvStream& ReadWallpaper( SvStream& rIStm, Wallpaper& rWallpaper ); + friend SvStream& WriteWallpaper( SvStream& rOStm, const Wallpaper& rWallpaper ); +}; + +#endif // INCLUDED_VCL_WALL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx new file mode 100644 index 000000000..0d58711d1 --- /dev/null +++ b/include/vcl/weld.hxx @@ -0,0 +1,2388 @@ +/* -*- 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_WELD_HXX +#define INCLUDED_VCL_WELD_HXX + +#include <basegfx/range/b2irange.hxx> +#include <rtl/ustring.hxx> +#include <tools/color.hxx> +#include <tools/date.hxx> +#include <tools/fldunit.hxx> +#include <tools/gen.hxx> +#include <tools/link.hxx> +#include <tools/time.hxx> +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> +#include <vcl/font.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/uitest/factory.hxx> + +#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> + +#include <boost/property_tree/ptree_fwd.hpp> + +#include <assert.h> +#include <memory> +#include <vector> + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace awt +{ +class XWindow; +} +namespace datatransfer +{ +namespace dnd +{ +class XDropTarget; +} +} +namespace graphic +{ +class XGraphic; +} +} +} +} + +typedef css::uno::Reference<css::accessibility::XAccessible> a11yref; +typedef css::uno::Reference<css::accessibility::XAccessibleRelationSet> a11yrelationset; + +enum class PointerStyle; +class CommandEvent; +class InputContext; +class KeyEvent; +class MouseEvent; +class SvNumberFormatter; +class TransferDataContainer; +class OutputDevice; +class VirtualDevice; +struct SystemEnvData; + +namespace vcl +{ +class ILibreOfficeKitNotifier; +typedef OutputDevice RenderContext; +} + +namespace weld +{ +class Container; +class DialogController; + +class VCL_DLLPUBLIC Widget +{ +protected: + Link<Widget&, void> m_aFocusInHdl; + Link<Widget&, void> m_aFocusOutHdl; + Link<Widget&, bool> m_aMnemonicActivateHdl; + Link<const Size&, void> m_aSizeAllocateHdl; + Link<const KeyEvent&, bool> m_aKeyPressHdl; + Link<const KeyEvent&, bool> m_aKeyReleaseHdl; + Link<const MouseEvent&, bool> m_aMousePressHdl; + Link<const MouseEvent&, bool> m_aMouseMotionHdl; + Link<const MouseEvent&, bool> m_aMouseReleaseHdl; + +public: + virtual void set_sensitive(bool sensitive) = 0; + virtual bool get_sensitive() const = 0; + virtual void show() = 0; + virtual void hide() = 0; + // This function simply calls show() or hide() but is convenient when the + // visibility depends on some condition + virtual void set_visible(bool visible) + { + if (visible) + show(); + else + hide(); + } + virtual bool get_visible() const = 0; //if this widget visibility is true + virtual bool is_visible() const = 0; //if this widget visibility and all parents is true + virtual void set_can_focus(bool bCanFocus) = 0; + virtual void grab_focus() = 0; + virtual bool has_focus() const = 0; + virtual bool is_active() const = 0; //if this widget has the focus within the active window + virtual void set_has_default(bool has_default) = 0; + virtual bool get_has_default() const = 0; + virtual void set_size_request(int nWidth, int nHeight) = 0; + virtual Size get_size_request() const = 0; + virtual Size get_preferred_size() const = 0; + virtual float get_approximate_digit_width() const = 0; + virtual int get_text_height() const = 0; + virtual Size get_pixel_size(const OUString& rText) const = 0; + virtual OString get_buildable_name() const = 0; + virtual void set_help_id(const OString& rName) = 0; + virtual OString get_help_id() const = 0; + + virtual void set_grid_left_attach(int nAttach) = 0; + virtual int get_grid_left_attach() const = 0; + virtual void set_grid_width(int nCols) = 0; + virtual void set_grid_top_attach(int nAttach) = 0; + virtual int get_grid_top_attach() const = 0; + + virtual void set_hexpand(bool bExpand) = 0; + virtual bool get_hexpand() const = 0; + virtual void set_vexpand(bool bExpand) = 0; + virtual bool get_vexpand() const = 0; + + virtual void set_secondary(bool bSecondary) = 0; + + virtual void set_margin_top(int nMargin) = 0; + virtual void set_margin_bottom(int nMargin) = 0; + virtual void set_margin_left(int nMargin) = 0; + virtual void set_margin_right(int nMargin) = 0; + + virtual int get_margin_top() const = 0; + virtual int get_margin_bottom() const = 0; + virtual int get_margin_left() const = 0; + virtual int get_margin_right() const = 0; + + /* + * Report the extents of this widget relative to the rRelative target widget. + * + * To succeed, both widgets must be realized, and must share a common toplevel. + * + * returns false if the relative extents could not be determined, e.g. if + * either widget was not realized, or there was no common ancestor. + * Otherwise true. + */ + virtual bool get_extents_relative_to(Widget& rRelative, int& x, int& y, int& width, int& height) + = 0; + + virtual void set_accessible_name(const OUString& rName) = 0; + virtual OUString get_accessible_name() const = 0; + + virtual OUString get_accessible_description() const = 0; + + virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0; + virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) = 0; + + virtual void set_tooltip_text(const OUString& rTip) = 0; + virtual OUString get_tooltip_text() const = 0; + + virtual void connect_focus_in(const Link<Widget&, void>& rLink) + { + assert(!m_aFocusInHdl.IsSet() || !rLink.IsSet()); + m_aFocusInHdl = rLink; + } + + virtual void connect_focus_out(const Link<Widget&, void>& rLink) + { + assert(!m_aFocusOutHdl.IsSet() || !rLink.IsSet()); + m_aFocusOutHdl = rLink; + } + + // rLink is called when the mnemonic for the Widget is called. + // If rLink returns true the Widget will not automatically gain + // focus as normally occurs + virtual void connect_mnemonic_activate(const Link<Widget&, bool>& rLink) + { + assert(!m_aMnemonicActivateHdl.IsSet() || !rLink.IsSet()); + m_aMnemonicActivateHdl = rLink; + } + + virtual void connect_size_allocate(const Link<const Size&, void>& rLink) + { + assert(!m_aSizeAllocateHdl.IsSet() || !rLink.IsSet()); + m_aSizeAllocateHdl = rLink; + } + + virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) + { + assert(!m_aKeyPressHdl.IsSet() || !rLink.IsSet()); + m_aKeyPressHdl = rLink; + } + + virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink) + { + assert(!m_aKeyReleaseHdl.IsSet() || !rLink.IsSet()); + m_aKeyReleaseHdl = rLink; + } + + virtual void connect_mouse_press(const Link<const MouseEvent&, bool>& rLink) + { + assert(!m_aMousePressHdl.IsSet() || !rLink.IsSet()); + m_aMousePressHdl = rLink; + } + + virtual void connect_mouse_move(const Link<const MouseEvent&, bool>& rLink) + { + assert(!m_aMouseMotionHdl.IsSet() || !rLink.IsSet()); + m_aMouseMotionHdl = rLink; + } + + virtual void connect_mouse_release(const Link<const MouseEvent&, bool>& rLink) + { + assert(!m_aMouseReleaseHdl.IsSet() || !rLink.IsSet()); + m_aMouseReleaseHdl = rLink; + } + + virtual void grab_add() = 0; + virtual bool has_grab() const = 0; + virtual void grab_remove() = 0; + + // font size is in points, not pixels, e.g. see Window::[G]etPointFont + virtual vcl::Font get_font() = 0; + + //true for rtl, false otherwise + virtual bool get_direction() const = 0; + virtual void set_direction(bool bRTL) = 0; + + virtual void freeze() = 0; + virtual void thaw() = 0; + + virtual std::unique_ptr<Container> weld_parent() const = 0; + + //iterate upwards through the hierarchy starting at this widgets parent, + //calling func with their helpid until func returns true or we run out of + //parents + virtual void help_hierarchy_foreach(const std::function<bool(const OString&)>& func) = 0; + + virtual OUString strip_mnemonic(const OUString& rLabel) const = 0; + + virtual VclPtr<VirtualDevice> create_virtual_device() const = 0; + + //make this widget look like a page in a notebook + virtual void set_stack_background() = 0; + //make this widget look like it has a highlighted background + virtual void set_highlight_background() = 0; + //make this widget suitable for use in a toolbar + virtual void set_toolbar_background() = 0; + + virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> get_drop_target() = 0; + + virtual void connect_get_property_tree(const Link<boost::property_tree::ptree&, void>& rLink) + = 0; + + // render the widget to an output device + virtual void draw(VirtualDevice& rOutput) = 0; + + virtual ~Widget() {} +}; + +class VCL_DLLPUBLIC Container : virtual public Widget +{ +public: + // remove and add in one go + virtual void move(weld::Widget* pWidget, weld::Container* pNewParent) = 0; + // recursively unset has-default on any buttons in the widget hierarchy + virtual void recursively_unset_default_buttons() = 0; + // create an XWindow as a child of this container. The XWindow is + // suitable to contain css::awt::XControl items + virtual css::uno::Reference<css::awt::XWindow> CreateChildFrame() = 0; +}; + +class VCL_DLLPUBLIC Box : virtual public Container +{ +public: + // Moves child to a new position in the list of children + virtual void reorder_child(weld::Widget* pWidget, int position) = 0; +}; + +class VCL_DLLPUBLIC Paned : virtual public Container +{ +public: + // set pixel position of divider + virtual void set_position(int nPos) = 0; + // get pixel position of divider + virtual int get_position() const = 0; +}; + +class VCL_DLLPUBLIC ScrolledWindow : virtual public Container +{ +protected: + Link<ScrolledWindow&, void> m_aVChangeHdl; + Link<ScrolledWindow&, void> m_aHChangeHdl; + + void signal_vadjustment_changed() { m_aVChangeHdl.Call(*this); } + void signal_hadjustment_changed() { m_aHChangeHdl.Call(*this); } + +public: + virtual void set_user_managed_scrolling() = 0; + + virtual void hadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) + = 0; + virtual int hadjustment_get_value() const = 0; + virtual void hadjustment_set_value(int value) = 0; + virtual int hadjustment_get_upper() const = 0; + virtual void hadjustment_set_upper(int upper) = 0; + virtual int hadjustment_get_page_size() const = 0; + virtual void hadjustment_set_page_size(int size) = 0; + virtual void hadjustment_set_page_increment(int size) = 0; + virtual void hadjustment_set_step_increment(int size) = 0; + virtual void set_hpolicy(VclPolicyType eHPolicy) = 0; + virtual VclPolicyType get_hpolicy() const = 0; + void connect_hadjustment_changed(const Link<ScrolledWindow&, void>& rLink) + { + m_aHChangeHdl = rLink; + } + virtual int get_hscroll_height() const = 0; + + virtual void vadjustment_configure(int value, int lower, int upper, int step_increment, + int page_increment, int page_size) + = 0; + virtual int vadjustment_get_value() const = 0; + virtual void vadjustment_set_value(int value) = 0; + virtual int vadjustment_get_upper() const = 0; + virtual void vadjustment_set_upper(int upper) = 0; + virtual int vadjustment_get_page_size() const = 0; + virtual void vadjustment_set_page_size(int size) = 0; + virtual void vadjustment_set_page_increment(int size) = 0; + virtual void vadjustment_set_step_increment(int size) = 0; + virtual int vadjustment_get_lower() const = 0; + virtual void vadjustment_set_lower(int upper) = 0; + virtual void set_vpolicy(VclPolicyType eVPolicy) = 0; + virtual VclPolicyType get_vpolicy() const = 0; + void connect_vadjustment_changed(const Link<ScrolledWindow&, void>& rLink) + { + m_aVChangeHdl = rLink; + } + virtual int get_vscroll_width() const = 0; +}; + +class Label; + +class VCL_DLLPUBLIC Frame : virtual public Container +{ +public: + virtual void set_label(const OUString& rText) = 0; + virtual OUString get_label() const = 0; + virtual std::unique_ptr<Label> weld_label_widget() const = 0; +}; + +class VCL_DLLPUBLIC Notebook : virtual public Container +{ +protected: + Link<const OString&, bool> m_aLeavePageHdl; + Link<const OString&, void> m_aEnterPageHdl; + +public: + virtual int get_current_page() const = 0; + virtual OString get_page_ident(int nPage) const = 0; + virtual OString get_current_page_ident() const = 0; + virtual void set_current_page(int nPage) = 0; + virtual void set_current_page(const OString& rIdent) = 0; + virtual void remove_page(const OString& rIdent) = 0; + virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) = 0; + void append_page(const OString& rIdent, const OUString& rLabel) + { + insert_page(rIdent, rLabel, -1); + } + virtual void set_tab_label_text(const OString& rIdent, const OUString& rLabel) = 0; + virtual OUString get_tab_label_text(const OString& rIdent) const = 0; + virtual int get_n_pages() const = 0; + virtual weld::Container* get_page(const OString& rIdent) const = 0; + + void connect_leave_page(const Link<const OString&, bool>& rLink) { m_aLeavePageHdl = rLink; } + + void connect_enter_page(const Link<const OString&, void>& rLink) { m_aEnterPageHdl = rLink; } +}; + +class VCL_DLLPUBLIC ScreenShotEntry +{ +public: + ScreenShotEntry(const OString& rHelpId, const basegfx::B2IRange& rB2IRange) + : msHelpId(rHelpId) + , maB2IRange(rB2IRange) + { + } + + const basegfx::B2IRange& getB2IRange() const { return maB2IRange; } + + const OString& GetHelpId() const { return msHelpId; } + +private: + OString msHelpId; + basegfx::B2IRange maB2IRange; +}; + +typedef std::vector<ScreenShotEntry> ScreenShotCollection; + +class VCL_DLLPUBLIC Window : virtual public Container +{ +protected: + Link<Widget&, bool> m_aHelpRequestHdl; + Link<Widget&, void> m_aTopLevelFocusChangedHdl; + + void signal_toplevel_focus_changed() { m_aTopLevelFocusChangedHdl.Call(*this); } + +public: + virtual void set_title(const OUString& rTitle) = 0; + virtual OUString get_title() const = 0; + virtual void set_busy_cursor(bool bBusy) = 0; + virtual void window_move(int x, int y) = 0; + virtual void set_modal(bool bModal) = 0; + virtual bool get_modal() const = 0; + virtual bool get_resizable() const = 0; + virtual Size get_size() const = 0; + virtual Point get_position() const = 0; + virtual tools::Rectangle get_monitor_workarea() const = 0; + // center window on is parent + // + // bTrackGeometryRequests set to true tries to ensure the window will end + // up still centered on its parent windows final size, taking into account + // that there may currently be pending geometry requests for the parent not + // yet processed by the underlying toolkit + // + // for e.g gtk this will means the window is always centered even when + // resized, calling set_centered_on_parent with false will turn this + // off again. + virtual void set_centered_on_parent(bool bTrackGeometryRequests) = 0; + virtual bool has_toplevel_focus() const = 0; + virtual void present() = 0; + virtual void set_window_state(const OString& rStr) = 0; + virtual OString get_window_state(WindowStateMask nMask) const = 0; + + virtual css::uno::Reference<css::awt::XWindow> GetXWindow() = 0; + + void connect_help(const Link<Widget&, bool>& rLink) { m_aHelpRequestHdl = rLink; } + virtual void connect_toplevel_focus_changed(const Link<Widget&, void>& rLink) + { + m_aTopLevelFocusChangedHdl = rLink; + } + + virtual SystemEnvData get_system_data() const = 0; + + virtual void resize_to_request() = 0; + + // collect positions of widgets and their help ids for screenshot purposes + virtual ScreenShotCollection collect_screenshot_data() = 0; +}; + +class VCL_DLLPUBLIC WaitObject +{ +private: + weld::Window* m_pWindow; + +public: + WaitObject(weld::Window* pWindow) + : m_pWindow(pWindow) + { + if (m_pWindow) + m_pWindow->set_busy_cursor(true); + } + ~WaitObject() + { + if (m_pWindow) + m_pWindow->set_busy_cursor(false); + } +}; + +class Button; + +class VCL_DLLPUBLIC Dialog : virtual public Window +{ +private: + friend DialogController; + virtual bool runAsync(std::shared_ptr<DialogController>, + const std::function<void(sal_Int32)>& func) + = 0; + +public: + virtual int run() = 0; + // Run async without a controller + // @param self - must point to this, to enforce that the dialog was created/held by a shared_ptr + virtual bool runAsync(std::shared_ptr<Dialog> const& rxSelf, + const std::function<void(sal_Int32)>& func) + = 0; + virtual void response(int response) = 0; + virtual void add_button(const OUString& rText, int response, const OString& rHelpId = OString()) + = 0; + virtual void set_default_response(int response) = 0; + virtual Button* weld_widget_for_response(int response) = 0; + virtual Container* weld_content_area() = 0; + + // shrink the dialog down to shown just these widgets + virtual void collapse(weld::Widget* pEdit, weld::Widget* pButton) = 0; + // undo previous dialog collapse + virtual void undo_collapse() = 0; + + virtual void SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>& rLink) + = 0; +}; + +class VCL_DLLPUBLIC MessageDialog : virtual public Dialog +{ +public: + virtual void set_primary_text(const OUString& rText) = 0; + virtual OUString get_primary_text() const = 0; + virtual void set_secondary_text(const OUString& rText) = 0; + virtual OUString get_secondary_text() const = 0; + virtual Container* weld_message_area() = 0; +}; + +class VCL_DLLPUBLIC AboutDialog : virtual public Dialog +{ +public: + virtual void set_version(const OUString& rVersion) = 0; + virtual void set_copyright(const OUString& rCopyright) = 0; + virtual void set_website(const OUString& rURL) = 0; + virtual void set_website_label(const OUString& rLabel) = 0; + virtual OUString get_website_label() const = 0; + virtual void set_logo(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0; + virtual void set_background(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0; +}; + +class VCL_DLLPUBLIC Assistant : virtual public Dialog +{ +protected: + Link<const OString&, bool> m_aJumpPageHdl; + + bool signal_jump_page(const OString& rIdent) { return m_aJumpPageHdl.Call(rIdent); } + +public: + virtual int get_current_page() const = 0; + virtual int get_n_pages() const = 0; + virtual OString get_page_ident(int nPage) const = 0; + virtual OString get_current_page_ident() const = 0; + virtual void set_current_page(int nPage) = 0; + virtual void set_current_page(const OString& rIdent) = 0; + // move the page rIdent to position nIndex + virtual void set_page_index(const OString& rIdent, int nIndex) = 0; + virtual void set_page_title(const OString& rIdent, const OUString& rTitle) = 0; + virtual OUString get_page_title(const OString& rIdent) const = 0; + virtual void set_page_sensitive(const OString& rIdent, bool bSensitive) = 0; + virtual weld::Container* append_page(const OString& rIdent) = 0; + + virtual void set_page_side_help_id(const OString& rHelpId) = 0; + + void connect_jump_page(const Link<const OString&, bool>& rLink) { m_aJumpPageHdl = rLink; } +}; + +struct VCL_DLLPUBLIC ComboBoxEntry +{ + OUString sString; + OUString sId; + OUString sImage; + ComboBoxEntry(const OUString& rString) + : sString(rString) + { + } + ComboBoxEntry(const OUString& rString, const OUString& rId) + : sString(rString) + , sId(rId) + { + } + ComboBoxEntry(const OUString& rString, const OUString& rId, const OUString& rImage) + : sString(rString) + , sId(rId) + , sImage(rImage) + { + } +}; + +enum class EntryMessageType +{ + Normal, + Warning, + Error, +}; + +class Menu; + +/// A widget used to choose from a list of items. +class VCL_DLLPUBLIC ComboBox : virtual public Container +{ +private: + OUString m_sSavedValue; + +public: + // OUString is the id of the row, it may be null to measure the height of a generic line + typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&> + render_args; + +protected: + Link<ComboBox&, void> m_aChangeHdl; + Link<ComboBox&, void> m_aPopupToggledHdl; + Link<ComboBox&, bool> m_aEntryActivateHdl; + Link<OUString&, bool> m_aEntryInsertTextHdl; + + void signal_changed() { m_aChangeHdl.Call(*this); } + virtual void signal_popup_toggled() { m_aPopupToggledHdl.Call(*this); } + + Link<render_args, void> m_aRenderHdl; + void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect, + bool bSelected, const OUString& rId) + { + m_aRenderHdl.Call( + std::tuple<vcl::RenderContext&, const tools::Rectangle, bool, const OUString&>( + rDevice, rRect, bSelected, rId)); + } + + Link<vcl::RenderContext&, Size> m_aGetSizeHdl; + Size signal_custom_get_size(vcl::RenderContext& rDevice) { return m_aGetSizeHdl.Call(rDevice); } + +public: + virtual void insert(int pos, const OUString& rStr, const OUString* pId, + const OUString* pIconName, VirtualDevice* pImageSurface) + = 0; + virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, bool bKeepExisting) + = 0; + void insert_text(int pos, const OUString& rStr) + { + insert(pos, rStr, nullptr, nullptr, nullptr); + } + void append_text(const OUString& rStr) { insert(-1, rStr, nullptr, nullptr, nullptr); } + void append(const OUString& rId, const OUString& rStr) + { + insert(-1, rStr, &rId, nullptr, nullptr); + } + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(-1, rStr, &rId, &rImage, nullptr); + } + void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage) + { + insert(-1, rStr, &rId, nullptr, &rImage); + } + virtual void insert_separator(int pos, const OUString& rId) = 0; + void append_separator(const OUString& rId) { insert_separator(-1, rId); } + + virtual int get_count() const = 0; + virtual void make_sorted() = 0; + virtual void clear() = 0; + + //by index + virtual int get_active() const = 0; + virtual void set_active(int pos) = 0; + virtual void remove(int pos) = 0; + + //by text + virtual OUString get_active_text() const = 0; + void set_active_text(const OUString& rStr) { set_active(find_text(rStr)); } + virtual OUString get_text(int pos) const = 0; + virtual int find_text(const OUString& rStr) const = 0; + void remove_text(const OUString& rText) { remove(find_text(rText)); } + + //by id + virtual OUString get_active_id() const = 0; + virtual void set_active_id(const OUString& rStr) = 0; + virtual OUString get_id(int pos) const = 0; + virtual void set_id(int row, const OUString& rId) = 0; + virtual int find_id(const OUString& rId) const = 0; + void remove_id(const OUString& rId) { remove(find_id(rId)); } + + /* m_aChangeHdl is called when the active item is changed. The can be due + to the user selecting a different item from the list or while typing + into the entry of a combo box with an entry. + + Use changed_by_direct_pick() to discover whether an item was actually explicitly + selected, e.g. from the menu. + */ + void connect_changed(const Link<ComboBox&, void>& rLink) { m_aChangeHdl = rLink; } + + virtual bool changed_by_direct_pick() const = 0; + + virtual void connect_popup_toggled(const Link<ComboBox&, void>& rLink) + { + m_aPopupToggledHdl = rLink; + } + + //entry related + virtual bool has_entry() const = 0; + virtual void set_entry_message_type(EntryMessageType eType) = 0; + virtual void set_entry_text(const OUString& rStr) = 0; + virtual void set_entry_width_chars(int nChars) = 0; + virtual void set_entry_max_length(int nChars) = 0; + virtual void select_entry_region(int nStartPos, int nEndPos) = 0; + virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) = 0; + virtual void set_entry_completion(bool bEnable, bool bCaseSensitive = false) = 0; + virtual void set_entry_placeholder_text(const OUString& rText) = 0; + virtual void set_entry_editable(bool bEditable) = 0; + virtual void cut_entry_clipboard() = 0; + virtual void copy_entry_clipboard() = 0; + virtual void paste_entry_clipboard() = 0; + + // font size is in points, not pixels, e.g. see Window::[G]etPointFont + virtual void set_entry_font(const vcl::Font& rFont) = 0; + virtual vcl::Font get_entry_font() = 0; + + virtual bool get_popup_shown() const = 0; + + void connect_entry_insert_text(const Link<OUString&, bool>& rLink) + { + m_aEntryInsertTextHdl = rLink; + } + + // callback returns true to indicated no further processing of activate wanted + void connect_entry_activate(const Link<ComboBox&, bool>& rLink) { m_aEntryActivateHdl = rLink; } + + void save_value() { m_sSavedValue = get_active_text(); } + OUString const& get_saved_value() const { return m_sSavedValue; } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_active_text(); } + + // for custom rendering a row + void connect_custom_get_size(const Link<vcl::RenderContext&, Size>& rLink) + { + m_aGetSizeHdl = rLink; + } + void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; } + // call set_custom_renderer after setting custom callbacks + virtual void set_custom_renderer(bool bOn) = 0; + // create a virtual device compatible with the device passed in render_args wrt alpha + virtual VclPtr<VirtualDevice> create_render_virtual_device() const = 0; + // set a sub menu for a entry, only works with custom rendering + virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) = 0; + // get the width needed to show the menu launcher in a custom row + virtual int get_menu_button_width() const = 0; + + // for mru support + virtual int get_max_mru_count() const = 0; + virtual void set_max_mru_count(int nCount) = 0; + virtual OUString get_mru_entries() const = 0; + virtual void set_mru_entries(const OUString& rEntries) = 0; +}; + +class VCL_DLLPUBLIC TreeIter +{ +private: + TreeIter(const TreeIter&) = delete; + TreeIter& operator=(const TreeIter&) = delete; + +public: + TreeIter() {} + virtual bool equal(const TreeIter& rOther) const = 0; + virtual ~TreeIter() {} +}; + +class VCL_DLLPUBLIC TreeView : virtual public Container +{ +private: + OUString m_sSavedValue; + +protected: + Link<TreeView&, void> m_aChangeHdl; + Link<TreeView&, bool> m_aRowActivatedHdl; + Link<int, void> m_aColumnClickedHdl; + Link<const std::pair<int, int>&, void> m_aRadioToggleHdl; + Link<const TreeIter&, bool> m_aEditingStartedHdl; + Link<const std::pair<const TreeIter&, OUString>&, bool> m_aEditingDoneHdl; + // if handler returns false, the expansion of the row is refused + Link<const TreeIter&, bool> m_aExpandingHdl; + // if handler returns false, the collapse of the row is refused + Link<const TreeIter&, bool> m_aCollapsingHdl; + Link<TreeView&, void> m_aVisibleRangeChangedHdl; + Link<TreeView&, void> m_aModelChangedHdl; + // if handler returns true, then menu has been show and event is consumed + Link<const CommandEvent&, bool> m_aPopupMenuHdl; + // if handler returns true, drag is disallowed, consumer can change bool + // arg to false to disable the treeview default dnd icon + Link<bool&, bool> m_aDragBeginHdl; + std::function<int(const weld::TreeIter&, const weld::TreeIter&)> m_aCustomSort; + +public: + // OUString is the id of the row, it may be null to measure the height of a generic line + typedef std::pair<vcl::RenderContext&, const OUString&> get_size_args; + typedef std::tuple<vcl::RenderContext&, const tools::Rectangle&, bool, const OUString&> + render_args; + +protected: + std::vector<int> m_aRadioIndexes; + + void signal_changed() { m_aChangeHdl.Call(*this); } + bool signal_row_activated() { return m_aRowActivatedHdl.Call(*this); } + void signal_column_clicked(int nColumn) { m_aColumnClickedHdl.Call(nColumn); } + bool signal_expanding(const TreeIter& rIter) + { + return !m_aExpandingHdl.IsSet() || m_aExpandingHdl.Call(rIter); + } + bool signal_collapsing(const TreeIter& rIter) + { + return !m_aCollapsingHdl.IsSet() || m_aCollapsingHdl.Call(rIter); + } + void signal_visible_range_changed() { m_aVisibleRangeChangedHdl.Call(*this); } + void signal_model_changed() { m_aModelChangedHdl.Call(*this); } + + // arg is pair<row,col> + void signal_toggled(const std::pair<int, int>& rRowCol) { m_aRadioToggleHdl.Call(rRowCol); } + + bool signal_editing_started(const TreeIter& rIter) { return m_aEditingStartedHdl.Call(rIter); } + + bool signal_editing_done(const std::pair<const TreeIter&, OUString>& rIterText) + { + return m_aEditingDoneHdl.Call(rIterText); + } + + Link<const TreeIter&, OUString> m_aQueryTooltipHdl; + OUString signal_query_tooltip(const TreeIter& rIter) { return m_aQueryTooltipHdl.Call(rIter); } + + Link<render_args, void> m_aRenderHdl; + void signal_custom_render(vcl::RenderContext& rDevice, const tools::Rectangle& rRect, + bool bSelected, const OUString& rId) + { + m_aRenderHdl.Call( + std::tuple<vcl::RenderContext&, const tools::Rectangle, bool, const OUString&>( + rDevice, rRect, bSelected, rId)); + } + + Link<get_size_args, Size> m_aGetSizeHdl; + Size signal_custom_get_size(vcl::RenderContext& rDevice, const OUString& rId) + { + return m_aGetSizeHdl.Call(std::pair<vcl::RenderContext&, const OUString&>(rDevice, rId)); + } + +public: + virtual void connect_query_tooltip(const Link<const TreeIter&, OUString>& rLink) + { + assert(!m_aQueryTooltipHdl.IsSet() || !rLink.IsSet()); + m_aQueryTooltipHdl = rLink; + } + + virtual void insert(const TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, VirtualDevice* pImageSurface, + const OUString* pExpanderName, bool bChildrenOnDemand, TreeIter* pRet) + = 0; + + void insert(int nRow, TreeIter* pRet = nullptr) + { + insert(nullptr, nRow, nullptr, nullptr, nullptr, nullptr, nullptr, false, pRet); + } + + void append(TreeIter* pRet = nullptr) { insert(-1, pRet); } + + void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName, + VirtualDevice* pImageSurface) + { + insert(nullptr, pos, &rStr, pId, pIconName, pImageSurface, nullptr, false, nullptr); + } + void insert_text(int pos, const OUString& rStr) + { + insert(nullptr, pos, &rStr, nullptr, nullptr, nullptr, nullptr, false, nullptr); + } + void append_text(const OUString& rStr) + { + insert(nullptr, -1, &rStr, nullptr, nullptr, nullptr, nullptr, false, nullptr); + } + void append(const OUString& rId, const OUString& rStr) + { + insert(nullptr, -1, &rStr, &rId, nullptr, nullptr, nullptr, false, nullptr); + } + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(nullptr, -1, &rStr, &rId, &rImage, nullptr, nullptr, false, nullptr); + } + void append(const TreeIter* pParent, const OUString& rId, const OUString& rStr, + const OUString& rImage) + { + insert(pParent, -1, &rStr, &rId, &rImage, nullptr, nullptr, false, nullptr); + } + void append(const TreeIter* pParent, const OUString& rStr) + { + insert(pParent, -1, &rStr, nullptr, nullptr, nullptr, nullptr, false, nullptr); + } + void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage) + { + insert(nullptr, -1, &rStr, &rId, nullptr, &rImage, nullptr, false, nullptr); + } + + void connect_changed(const Link<TreeView&, void>& rLink) { m_aChangeHdl = rLink; } + + /* A row is "activated" when the user double clicks a treeview row. It may + also be emitted when a row is selected and Space or Enter is pressed. + + a return of "true" means the activation has been handled, a "false" propagates + the activation to the default handler which expands/collapses the row, if possible. + */ + void connect_row_activated(const Link<TreeView&, bool>& rLink) { m_aRowActivatedHdl = rLink; } + + // Argument is a pair of row, col describing the node in non-tree mode. + // If in tree mode, then retrieve the toggled node with get_cursor + void connect_toggled(const Link<const std::pair<int, int>&, void>& rLink) + { + m_aRadioToggleHdl = rLink; + } + + void connect_column_clicked(const Link<int, void>& rLink) { m_aColumnClickedHdl = rLink; } + void connect_model_changed(const Link<TreeView&, void>& rLink) { m_aModelChangedHdl = rLink; } + + virtual OUString get_selected_text() const = 0; + virtual OUString get_selected_id() const = 0; + + //by index + virtual int get_selected_index() const = 0; + //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + virtual void select(int pos) = 0; + virtual void unselect(int pos) = 0; + virtual void remove(int pos) = 0; + virtual OUString get_text(int row, int col = -1) const = 0; + virtual void set_text(int row, const OUString& rText, int col = -1) = 0; + virtual void set_sensitive(int row, bool bSensitive, int col = -1) = 0; + virtual void set_id(int row, const OUString& rId) = 0; + virtual void set_toggle(int row, TriState eState, int col) = 0; + virtual TriState get_toggle(int row, int col) const = 0; + virtual void set_image(int row, const OUString& rImage, int col = -1) = 0; + virtual void set_image(int row, VirtualDevice& rImage, int col = -1) = 0; + virtual void set_image(int row, const css::uno::Reference<css::graphic::XGraphic>& rImage, + int col = -1) + = 0; + virtual void set_text_emphasis(int row, bool bOn, int col) = 0; + virtual bool get_text_emphasis(int row, int col) const = 0; + virtual void set_text_align(int row, double fAlign, int col) = 0; + virtual void swap(int pos1, int pos2) = 0; + virtual std::vector<int> get_selected_rows() const = 0; + virtual void set_font_color(int pos, const Color& rColor) = 0; + // scroll to make 'row' visible, this will also expand all parent rows of 'row' as necessary to + // make 'row' visible + virtual void scroll_to_row(int row) = 0; + virtual bool is_selected(int pos) const = 0; + virtual int get_cursor_index() const = 0; + virtual void set_cursor(int pos) = 0; + + //by text + virtual int find_text(const OUString& rText) const = 0; + //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + void select_text(const OUString& rText) { select(find_text(rText)); } + void remove_text(const OUString& rText) { remove(find_text(rText)); } + std::vector<OUString> get_selected_rows_text() const + { + std::vector<int> aRows(get_selected_rows()); + std::vector<OUString> aRet; + aRet.reserve(aRows.size()); + for (auto a : aRows) + aRet.push_back(get_text(a)); + return aRet; + } + + //by id + virtual OUString get_id(int pos) const = 0; + virtual int find_id(const OUString& rId) const = 0; + //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + void select_id(const OUString& rId) { select(find_id(rId)); } + void remove_id(const OUString& rText) { remove(find_id(rText)); } + + //via iter + virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0; + virtual void copy_iterator(const TreeIter& rSource, TreeIter& rDest) const = 0; + virtual bool get_selected(TreeIter* pIter) const = 0; + virtual bool get_cursor(TreeIter* pIter) const = 0; + virtual void set_cursor(const TreeIter& rIter) = 0; + virtual bool get_iter_first(TreeIter& rIter) const = 0; + // set iter to point to next node at the current level + virtual bool iter_next_sibling(TreeIter& rIter) const = 0; + // set iter to point to previous node at the current level + virtual bool iter_previous_sibling(TreeIter& rIter) const = 0; + // set iter to point to next node, depth first, then sibling + virtual bool iter_next(TreeIter& rIter) const = 0; + // set iter to point to previous node, sibling first then depth + virtual bool iter_previous(TreeIter& rIter) const = 0; + // set iter to point to next node, depth first but only if expanded, then sibling + virtual bool iter_next_visible(TreeIter& rIter) const = 0; + virtual bool iter_children(TreeIter& rIter) const = 0; + bool iter_nth_sibling(TreeIter& rIter, int nChild) const + { + bool bRet = true; + for (int i = 0; i < nChild && bRet; ++i) + bRet = iter_next_sibling(rIter); + return bRet; + } + bool iter_nth_child(TreeIter& rIter, int nChild) const + { + if (!iter_children(rIter)) + return false; + return iter_nth_sibling(rIter, nChild); + } + virtual bool iter_parent(TreeIter& rIter) const = 0; + virtual int get_iter_depth(const TreeIter& rIter) const = 0; + virtual int get_iter_index_in_parent(const TreeIter& rIter) const = 0; + /* Compares two paths. If a appears before b in a tree, then -1 is returned. + If b appears before a , then 1 is returned. If the two nodes are equal, + then 0 is returned. + */ + virtual int iter_compare(const TreeIter& a, const TreeIter& b) const = 0; + virtual bool iter_has_child(const TreeIter& rIter) const = 0; + // returns the number of direct children rIter has + virtual int iter_n_children(const TreeIter& rIter) const = 0; + virtual void remove(const TreeIter& rIter) = 0; + //Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + virtual void select(const TreeIter& rIter) = 0; + virtual void unselect(const TreeIter& rIter) = 0; + virtual bool get_row_expanded(const TreeIter& rIter) const = 0; + virtual bool get_children_on_demand(const TreeIter& rIter) const = 0; + virtual void set_children_on_demand(const TreeIter& rIter, bool bChildrenOnDemand) = 0; + //visually indent this row as if it was at get_iter_depth() + nIndentLevel + virtual void set_extra_row_indent(const TreeIter& rIter, int nIndentLevel) = 0; + virtual void expand_row(const TreeIter& rIter) = 0; + virtual void collapse_row(const TreeIter& rIter) = 0; + virtual void set_text(const TreeIter& rIter, const OUString& rStr, int col = -1) = 0; + virtual void set_sensitive(const TreeIter& rIter, bool bSensitive, int col = -1) = 0; + virtual void set_text_emphasis(const TreeIter& rIter, bool bOn, int col) = 0; + virtual bool get_text_emphasis(const TreeIter& rIter, int col) const = 0; + virtual void set_text_align(const TreeIter& rIter, double fAlign, int col) = 0; + virtual void set_toggle(const TreeIter& rIter, TriState bOn, int col) = 0; + virtual TriState get_toggle(const TreeIter& rIter, int col) const = 0; + virtual OUString get_text(const TreeIter& rIter, int col = -1) const = 0; + virtual void set_id(const TreeIter& rIter, const OUString& rId) = 0; + virtual OUString get_id(const TreeIter& rIter) const = 0; + virtual void set_image(const TreeIter& rIter, const OUString& rImage, int col = -1) = 0; + virtual void set_image(const TreeIter& rIter, VirtualDevice& rImage, int col = -1) = 0; + virtual void set_image(const TreeIter& rIter, + const css::uno::Reference<css::graphic::XGraphic>& rImage, int col = -1) + = 0; + virtual void set_font_color(const TreeIter& rIter, const Color& rColor) = 0; + // scroll to make rIter visible, this will also expand all parent rows of rIter as necessary to + // make rIter visible + virtual void scroll_to_row(const TreeIter& rIter) = 0; + virtual bool is_selected(const TreeIter& rIter) const = 0; + + virtual void move_subtree(TreeIter& rNode, const TreeIter* pNewParent, int nIndexInNewParent) + = 0; + + // call func on each element until func returns true or we run out of elements + virtual void all_foreach(const std::function<bool(TreeIter&)>& func) = 0; + // call func on each selected element until func returns true or we run out of elements + virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0; + // call func on each visible element until func returns true or we run out of elements + virtual void visible_foreach(const std::function<bool(TreeIter&)>& func) = 0; + // clear the tree, then add nSourceCount rows, call func on each row + // inserted with an arg of the index that this row will be when bulk insert + // ends. + // + // this enables inserting the entries backwards in models where that is faster, + // + // pFixedWidths is optional, when present each matching entry col text + // width will not be measured, and the fixed width used instead. Use + // sparingly because wider text than the fixed width is clipped and cannot + // be scrolled into view horizontally. + virtual void bulk_insert_for_each(int nSourceCount, + const std::function<void(TreeIter&, int nSourceIndex)>& func, + const std::vector<int>* pFixedWidths = nullptr) + = 0; + + void connect_expanding(const Link<const TreeIter&, bool>& rLink) { m_aExpandingHdl = rLink; } + void connect_collapsing(const Link<const TreeIter&, bool>& rLink) { m_aCollapsingHdl = rLink; } + + // rStartLink returns true to allow editing, false to disallow + // rEndLink returns true to accept the edit, false to reject + virtual void + connect_editing(const Link<const TreeIter&, bool>& rStartLink, + const Link<const std::pair<const TreeIter&, OUString>&, bool>& rEndLink) + { + assert(rStartLink.IsSet() == rEndLink.IsSet() && "should be both on or both off"); + m_aEditingStartedHdl = rStartLink; + m_aEditingDoneHdl = rEndLink; + } + + virtual void start_editing(const weld::TreeIter& rEntry) = 0; + virtual void end_editing() = 0; + + virtual void connect_visible_range_changed(const Link<TreeView&, void>& rLink) + { + assert(!m_aVisibleRangeChangedHdl.IsSet() || !rLink.IsSet()); + m_aVisibleRangeChangedHdl = rLink; + } + + virtual void connect_popup_menu(const Link<const CommandEvent&, bool>& rLink) + { + m_aPopupMenuHdl = rLink; + } + + virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferrable, + sal_uInt8 eDNDConstants) + = 0; + + void connect_drag_begin(const Link<bool&, bool>& rLink) { m_aDragBeginHdl = rLink; } + + //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + void select_all() { unselect(-1); } + void unselect_all() { select(-1); } + + // return the number of toplevel nodes + virtual int n_children() const = 0; + + // afterwards, entries will be in default ascending sort order + virtual void make_sorted() = 0; + virtual void make_unsorted() = 0; + virtual bool get_sort_order() const = 0; + virtual void set_sort_order(bool bAscending) = 0; + + // TRUE ascending, FALSE, descending, INDET, neither (off) + virtual void set_sort_indicator(TriState eState, int nColumn = -1) = 0; + virtual TriState get_sort_indicator(int nColumn = -1) const = 0; + + virtual int get_sort_column() const = 0; + virtual void set_sort_column(int nColumn) = 0; + + virtual void + set_sort_func(const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func) + { + m_aCustomSort = func; + } + + virtual void clear() = 0; + virtual int get_height_rows(int nRows) const = 0; + + virtual void columns_autosize() = 0; + virtual void set_column_fixed_widths(const std::vector<int>& rWidths) = 0; + virtual void set_column_editables(const std::vector<bool>& rEditables) = 0; + virtual int get_column_width(int nCol) const = 0; + virtual void set_centered_column(int nCol) = 0; + virtual OUString get_column_title(int nColumn) const = 0; + virtual void set_column_title(int nColumn, const OUString& rTitle) = 0; + + int get_checkbox_column_width() const { return get_approximate_digit_width() * 3 + 6; } + + virtual void set_selection_mode(SelectionMode eMode) = 0; + virtual int count_selected_rows() const = 0; + // remove the selected nodes + virtual void remove_selection() = 0; + + void set_toggle_columns_as_radio(const std::vector<int>& rCols) { m_aRadioIndexes = rCols; } + + virtual void vadjustment_set_value(int value) = 0; + virtual int vadjustment_get_value() const = 0; + + void save_value() { m_sSavedValue = get_selected_text(); } + OUString const& get_saved_value() const { return m_sSavedValue; } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); } + + // for custom rendering a cell + void connect_custom_get_size(const Link<get_size_args, Size>& rLink) { m_aGetSizeHdl = rLink; } + void connect_custom_render(const Link<render_args, void>& rLink) { m_aRenderHdl = rLink; } + // call set_column_custom_renderer after setting custom callbacks + virtual void set_column_custom_renderer(int nColumn, bool bEnable) = 0; + + // for dnd + virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult, + bool bHighLightTarget = true) + = 0; + virtual void unset_drag_dest_row() = 0; + virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const = 0; + // for dragging and dropping between TreeViews, return the active source + virtual TreeView* get_drag_source() const = 0; + + using Widget::set_sensitive; +}; + +class VCL_DLLPUBLIC IconView : virtual public Container +{ +private: + OUString m_sSavedValue; + +protected: + Link<IconView&, void> m_aSelectionChangeHdl; + Link<IconView&, bool> m_aItemActivatedHdl; + + void signal_selection_changed() { m_aSelectionChangeHdl.Call(*this); } + bool signal_item_activated() { return m_aItemActivatedHdl.Call(*this); } + +public: + virtual void insert(int pos, const OUString* pStr, const OUString* pId, + const OUString* pIconName, TreeIter* pRet) + = 0; + + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(-1, &rStr, &rId, &rImage, nullptr); + } + + void connect_selection_changed(const Link<IconView&, void>& rLink) + { + m_aSelectionChangeHdl = rLink; + } + + /* A row is "activated" when the user double clicks a treeview row. It may + also be emitted when a row is selected and Space or Enter is pressed. + + a return of "true" means the activation has been handled, a "false" propagates + the activation to the default handler which expands/collapses the row, if possible. + */ + void connect_item_activated(const Link<IconView&, bool>& rLink) { m_aItemActivatedHdl = rLink; } + + virtual OUString get_selected_id() const = 0; + + virtual void clear() = 0; + + virtual int count_selected_items() const = 0; + + virtual OUString get_selected_text() const = 0; + + //by index. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + virtual void select(int pos) = 0; + virtual void unselect(int pos) = 0; + + //via iter + virtual std::unique_ptr<TreeIter> make_iterator(const TreeIter* pOrig = nullptr) const = 0; + virtual bool get_selected(TreeIter* pIter) const = 0; + virtual bool get_cursor(TreeIter* pIter) const = 0; + virtual void set_cursor(const TreeIter& rIter) = 0; + virtual bool get_iter_first(TreeIter& rIter) const = 0; + virtual OUString get_id(const TreeIter& rIter) const = 0; + virtual void scroll_to_item(const TreeIter& rIter) = 0; + + // call func on each selected element until func returns true or we run out of elements + virtual void selected_foreach(const std::function<bool(TreeIter&)>& func) = 0; + + //all of them. Don't select when frozen, select after thaw. Note selection doesn't survive a freeze. + void select_all() { unselect(-1); } + void unselect_all() { select(-1); } + + // return the number of toplevel nodes + virtual int n_children() const = 0; + + void save_value() { m_sSavedValue = get_selected_text(); } + OUString const& get_saved_value() const { return m_sSavedValue; } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_selected_text(); } +}; + +class VCL_DLLPUBLIC Button : virtual public Container +{ +protected: + Link<Button&, void> m_aClickHdl; + + void signal_clicked() { m_aClickHdl.Call(*this); } + +public: + virtual void set_label(const OUString& rText) = 0; + // pDevice, the image for the button, or nullptr to unset + virtual void set_image(VirtualDevice* pDevice) = 0; + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0; + virtual void set_from_icon_name(const OUString& rIconName) = 0; + virtual OUString get_label() const = 0; + virtual void set_label_line_wrap(bool wrap) = 0; + void clicked() { signal_clicked(); } + + void connect_clicked(const Link<Button&, void>& rLink) { m_aClickHdl = rLink; } +}; + +class VCL_DLLPUBLIC ToggleButton : virtual public Button +{ +protected: + Link<ToggleButton&, void> m_aToggleHdl; + TriState m_eSavedValue = TRISTATE_FALSE; + + void signal_toggled() { m_aToggleHdl.Call(*this); } + +public: + virtual void set_active(bool active) = 0; + virtual bool get_active() const = 0; + + virtual void set_inconsistent(bool inconsistent) = 0; + virtual bool get_inconsistent() const = 0; + + TriState get_state() const + { + if (get_inconsistent()) + return TRISTATE_INDET; + else if (get_active()) + return TRISTATE_TRUE; + return TRISTATE_FALSE; + } + + void set_state(TriState eState) + { + switch (eState) + { + case TRISTATE_INDET: + set_inconsistent(true); + break; + case TRISTATE_TRUE: + set_inconsistent(false); + set_active(true); + break; + case TRISTATE_FALSE: + set_inconsistent(false); + set_active(false); + break; + } + } + + void save_state() { m_eSavedValue = get_state(); } + TriState get_saved_state() const { return m_eSavedValue; } + bool get_state_changed_from_saved() const { return m_eSavedValue != get_state(); } + + virtual void connect_toggled(const Link<ToggleButton&, void>& rLink) { m_aToggleHdl = rLink; } +}; + +struct VCL_DLLPUBLIC TriStateEnabled +{ + TriState eState; + bool bTriStateEnabled; + TriStateEnabled() + : eState(TRISTATE_INDET) + , bTriStateEnabled(true) + { + } + void ButtonToggled(ToggleButton& rToggle); +}; + +class VCL_DLLPUBLIC MenuButton : virtual public ToggleButton +{ +protected: + Link<const OString&, void> m_aSelectHdl; + + void signal_selected(const OString& rIdent) { m_aSelectHdl.Call(rIdent); } + +public: + void connect_selected(const Link<const OString&, void>& rLink) { m_aSelectHdl = rLink; } + + virtual void insert_item(int pos, const OUString& rId, const OUString& rStr, + const OUString* pIconName, VirtualDevice* pImageSurface, + TriState eCheckRadioFalse) + = 0; + void append_item(const OUString& rId, const OUString& rStr) + { + insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_INDET); + } + void append_item_check(const OUString& rId, const OUString& rStr) + { + insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_TRUE); + } + void append_item_radio(const OUString& rId, const OUString& rStr) + { + insert_item(-1, rId, rStr, nullptr, nullptr, TRISTATE_FALSE); + } + void append_item(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert_item(-1, rId, rStr, &rImage, nullptr, TRISTATE_INDET); + } + void append_item(const OUString& rId, const OUString& rStr, VirtualDevice& rImage) + { + insert_item(-1, rId, rStr, nullptr, &rImage, TRISTATE_INDET); + } + virtual void insert_separator(int pos, const OUString& rId) = 0; + void append_separator(const OUString& rId) { insert_separator(-1, rId); } + virtual void remove_item(const OString& rId) = 0; + virtual void clear() = 0; + virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) = 0; + virtual void set_item_active(const OString& rIdent, bool bActive) = 0; + virtual void set_item_label(const OString& rIdent, const OUString& rLabel) = 0; + virtual OUString get_item_label(const OString& rIdent) const = 0; + virtual void set_item_help_id(const OString& rIdent, const OString& rHelpId) = 0; + virtual void set_item_visible(const OString& rIdent, bool bVisible) = 0; + virtual OString get_item_help_id(const OString& rIdent) const = 0; + + virtual void set_popover(weld::Widget* pPopover) = 0; +}; + +class VCL_DLLPUBLIC CheckButton : virtual public ToggleButton +{ +}; + +class VCL_DLLPUBLIC RadioButton : virtual public ToggleButton +{ +}; + +class VCL_DLLPUBLIC LinkButton : virtual public Container +{ +protected: + Link<LinkButton&, bool> m_aActivateLinkHdl; + + bool signal_activate_link() { return m_aActivateLinkHdl.Call(*this); } + +public: + virtual void set_label(const OUString& rText) = 0; + virtual OUString get_label() const = 0; + virtual void set_uri(const OUString& rUri) = 0; + virtual OUString get_uri() const = 0; + + void connect_activate_link(const Link<LinkButton&, bool>& rLink) { m_aActivateLinkHdl = rLink; } +}; + +class VCL_DLLPUBLIC Scale : virtual public Widget +{ +protected: + Link<Scale&, void> m_aValueChangedHdl; + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + +public: + virtual void set_value(int value) = 0; + virtual int get_value() const = 0; + virtual void set_range(int min, int max) = 0; + + virtual void set_increments(int step, int page) = 0; + virtual void get_increments(int& step, int& page) const = 0; + + void connect_value_changed(const Link<Scale&, void>& rLink) { m_aValueChangedHdl = rLink; } +}; + +class VCL_DLLPUBLIC Spinner : virtual public Widget +{ +public: + virtual void start() = 0; + virtual void stop() = 0; +}; + +class VCL_DLLPUBLIC ProgressBar : virtual public Widget +{ +public: + //0-100 + virtual void set_percentage(int value) = 0; + virtual OUString get_text() const = 0; + virtual void set_text(const OUString& rText) = 0; +}; + +class VCL_DLLPUBLIC Entry : virtual public Widget +{ +private: + OUString m_sSavedValue; + +protected: + Link<Entry&, void> m_aChangeHdl; + Link<OUString&, bool> m_aInsertTextHdl; + Link<Entry&, void> m_aCursorPositionHdl; + Link<Entry&, bool> m_aActivateHdl; + + void signal_changed() { m_aChangeHdl.Call(*this); } + void signal_cursor_position() { m_aCursorPositionHdl.Call(*this); } + void signal_insert_text(OUString& rString); + +public: + virtual void set_text(const OUString& rText) = 0; + virtual OUString get_text() const = 0; + virtual void set_width_chars(int nChars) = 0; + virtual int get_width_chars() const = 0; + // The maximum length of the entry. Use 0 for no maximum + virtual void set_max_length(int nChars) = 0; + // nEndPos can be -1 in order to select all text + virtual void select_region(int nStartPos, int nEndPos) = 0; + // returns true if the selection has nonzero length + virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0; + virtual void replace_selection(const OUString& rText) = 0; + // nCursorPos can be -1 to set to the end + virtual void set_position(int nCursorPos) = 0; + virtual int get_position() const = 0; + virtual void set_editable(bool bEditable) = 0; + virtual bool get_editable() const = 0; + virtual void set_message_type(EntryMessageType eType) = 0; + virtual void set_placeholder_text(const OUString& rText) = 0; + + // font size is in points, not pixels, e.g. see Window::[G]etPointFont + virtual void set_font(const vcl::Font& rFont) = 0; + + void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; } + void connect_insert_text(const Link<OUString&, bool>& rLink) { m_aInsertTextHdl = rLink; } + // callback returns true to indicated no further processing of activate wanted + void connect_activate(const Link<Entry&, bool>& rLink) { m_aActivateHdl = rLink; } + virtual void connect_cursor_position(const Link<Entry&, void>& rLink) + { + m_aCursorPositionHdl = rLink; + } + + virtual void cut_clipboard() = 0; + virtual void copy_clipboard() = 0; + virtual void paste_clipboard() = 0; + + void save_value() { m_sSavedValue = get_text(); } + OUString const& get_saved_value() const { return m_sSavedValue; } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); } +}; + +class VCL_DLLPUBLIC SpinButton : virtual public Entry +{ +protected: + Link<SpinButton&, void> m_aValueChangedHdl; + Link<SpinButton&, void> m_aOutputHdl; + Link<int*, bool> m_aInputHdl; + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + + bool signal_output() + { + if (!m_aOutputHdl.IsSet()) + return false; + m_aOutputHdl.Call(*this); + return true; + } + + TriState signal_input(int* result) + { + if (!m_aInputHdl.IsSet()) + return TRISTATE_INDET; + return m_aInputHdl.Call(result) ? TRISTATE_TRUE : TRISTATE_FALSE; + } + +public: + virtual void set_value(int value) = 0; + virtual int get_value() const = 0; + virtual void set_range(int min, int max) = 0; + virtual void get_range(int& min, int& max) const = 0; + void set_min(int min) + { + int dummy, max; + get_range(dummy, max); + set_range(min, max); + } + void set_max(int max) + { + int min, dummy; + get_range(min, dummy); + set_range(min, max); + } + int get_min() const + { + int min, dummy; + get_range(min, dummy); + return min; + } + int get_max() const + { + int dummy, max; + get_range(dummy, max); + return max; + } + virtual void set_increments(int step, int page) = 0; + virtual void get_increments(int& step, int& page) const = 0; + virtual void set_digits(unsigned int digits) = 0; + virtual unsigned int get_digits() const = 0; + + void connect_value_changed(const Link<SpinButton&, void>& rLink) { m_aValueChangedHdl = rLink; } + + void connect_output(const Link<SpinButton&, void>& rLink) { m_aOutputHdl = rLink; } + void connect_input(const Link<int*, bool>& rLink) { m_aInputHdl = rLink; } + + int normalize(int nValue) const { return (nValue * Power10(get_digits())); } + + int denormalize(int nValue) const; + + static unsigned int Power10(unsigned int n); +}; + +class VCL_DLLPUBLIC FormattedSpinButton : virtual public Entry +{ +protected: + Link<FormattedSpinButton&, void> m_aValueChangedHdl; + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + +public: + virtual void set_value(double value) = 0; + virtual double get_value() const = 0; + virtual void set_range(double min, double max) = 0; + virtual void get_range(double& min, double& max) const = 0; + + void set_max(double max) + { + double min, dummy; + get_range(min, dummy); + set_range(min, max); + } + + virtual void set_formatter(SvNumberFormatter* pFormatter) = 0; + virtual SvNumberFormatter* get_formatter() = 0; + virtual sal_Int32 get_format_key() const = 0; + virtual void set_format_key(sal_Int32 nFormatKey) = 0; + + virtual void set_digits(unsigned int digits) = 0; + + virtual void treat_as_number(bool bSet) = 0; + + void connect_value_changed(const Link<FormattedSpinButton&, void>& rLink) + { + m_aValueChangedHdl = rLink; + } +}; + +class VCL_DLLPUBLIC Image : virtual public Widget +{ +public: + virtual void set_from_icon_name(const OUString& rIconName) = 0; + virtual void set_image(VirtualDevice* pDevice) = 0; + virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0; +}; + +class VCL_DLLPUBLIC Calendar : virtual public Widget +{ +protected: + Link<Calendar&, void> m_aSelectedHdl; + Link<Calendar&, void> m_aActivatedHdl; + + void signal_selected() { m_aSelectedHdl.Call(*this); } + void signal_activated() { m_aActivatedHdl.Call(*this); } + +public: + void connect_selected(const Link<Calendar&, void>& rLink) { m_aSelectedHdl = rLink; } + void connect_activated(const Link<Calendar&, void>& rLink) { m_aActivatedHdl = rLink; } + + virtual void set_date(const Date& rDate) = 0; + virtual Date get_date() const = 0; +}; + +// an entry + treeview pair, where the entry autocompletes from the +// treeview list, and selecting something in the list sets the +// entry to that text, i.e. a visually exploded ComboBox +class VCL_DLLPUBLIC EntryTreeView : virtual public ComboBox +{ +private: + DECL_DLLPRIVATE_LINK(ClickHdl, weld::TreeView&, void); + DECL_DLLPRIVATE_LINK(ModifyHdl, weld::Entry&, void); + void EntryModifyHdl(const weld::Entry& rEntry); + +protected: + std::unique_ptr<Entry> m_xEntry; + std::unique_ptr<TreeView> m_xTreeView; + +public: + EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView); + + virtual void insert_vector(const std::vector<weld::ComboBoxEntry>& rItems, + bool bKeepExisting) override + { + m_xTreeView->freeze(); + if (!bKeepExisting) + m_xTreeView->clear(); + for (const auto& rItem : rItems) + { + m_xTreeView->insert(-1, rItem.sString, rItem.sId.isEmpty() ? nullptr : &rItem.sId, + rItem.sImage.isEmpty() ? nullptr : &rItem.sImage, nullptr); + } + m_xTreeView->thaw(); + } + + virtual void insert(int pos, const OUString& rStr, const OUString* pId, + const OUString* pIconName, VirtualDevice* pImageSurface) override + { + m_xTreeView->insert(pos, rStr, pId, pIconName, pImageSurface); + } + + virtual int get_count() const override { return m_xTreeView->n_children(); } + virtual void clear() override { m_xTreeView->clear(); } + + //by index + virtual int get_active() const override { return m_xTreeView->get_selected_index(); } + virtual void set_active(int pos) override + { + m_xTreeView->set_cursor(pos); + m_xTreeView->select(pos); + m_xEntry->set_text(m_xTreeView->get_selected_text()); + } + virtual void remove(int pos) override { m_xTreeView->remove(pos); } + + //by text + virtual OUString get_active_text() const override { return m_xEntry->get_text(); } + virtual OUString get_text(int pos) const override { return m_xTreeView->get_text(pos); } + virtual int find_text(const OUString& rStr) const override + { + return m_xTreeView->find_text(rStr); + } + + //by id + virtual OUString get_active_id() const override { return m_xTreeView->get_selected_id(); } + virtual void set_active_id(const OUString& rStr) override + { + m_xTreeView->select_id(rStr); + m_xEntry->set_text(m_xTreeView->get_selected_text()); + } + virtual OUString get_id(int pos) const override { return m_xTreeView->get_id(pos); } + virtual void set_id(int pos, const OUString& rId) override { m_xTreeView->set_id(pos, rId); } + virtual int find_id(const OUString& rId) const override { return m_xTreeView->find_id(rId); } + + //entry related + virtual bool has_entry() const override { return true; } + virtual void set_entry_message_type(EntryMessageType eType) override + { + m_xEntry->set_message_type(eType); + } + virtual void set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); } + virtual void set_entry_width_chars(int nChars) override { m_xEntry->set_width_chars(nChars); } + virtual void set_entry_max_length(int nChars) override { m_xEntry->set_max_length(nChars); } + virtual void select_entry_region(int nStartPos, int nEndPos) override + { + m_xEntry->select_region(nStartPos, nEndPos); + } + //if not text was selected, both rStartPos and rEndPos will be identical + //and false will be returned + virtual bool get_entry_selection_bounds(int& rStartPos, int& rEndPos) override + { + return m_xEntry->get_selection_bounds(rStartPos, rEndPos); + } + void connect_row_activated(const Link<TreeView&, bool>& rLink) + { + m_xTreeView->connect_row_activated(rLink); + } + + virtual bool get_popup_shown() const override { return false; } + + void set_height_request_by_rows(int nRows); +}; + +class VCL_DLLPUBLIC MetricSpinButton final +{ + FieldUnit m_eSrcUnit; + std::unique_ptr<weld::SpinButton> m_xSpinButton; + Link<MetricSpinButton&, void> m_aValueChangedHdl; + + DECL_LINK(spin_button_value_changed, weld::SpinButton&, void); + DECL_LINK(spin_button_output, weld::SpinButton&, void); + DECL_LINK(spin_button_input, int* result, bool); + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + + int ConvertValue(int nValue, FieldUnit eInUnit, FieldUnit eOutUnit) const; + OUString format_number(int nValue) const; + void update_width_chars(); + +public: + MetricSpinButton(std::unique_ptr<SpinButton> pSpinButton, FieldUnit eSrcUnit) + : m_eSrcUnit(eSrcUnit) + , m_xSpinButton(std::move(pSpinButton)) + { + update_width_chars(); + m_xSpinButton->connect_output(LINK(this, MetricSpinButton, spin_button_output)); + m_xSpinButton->connect_input(LINK(this, MetricSpinButton, spin_button_input)); + m_xSpinButton->connect_value_changed( + LINK(this, MetricSpinButton, spin_button_value_changed)); + spin_button_output(*m_xSpinButton); + } + + static OUString MetricToString(FieldUnit rUnit); + + FieldUnit get_unit() const { return m_eSrcUnit; } + + void set_unit(FieldUnit eUnit); + + int convert_value_to(int nValue, FieldUnit eValueUnit) const + { + return ConvertValue(nValue, m_eSrcUnit, eValueUnit); + } + + int convert_value_from(int nValue, FieldUnit eValueUnit) const + { + return ConvertValue(nValue, eValueUnit, m_eSrcUnit); + } + + void set_value(int nValue, FieldUnit eValueUnit) + { + m_xSpinButton->set_value(convert_value_from(nValue, eValueUnit)); + } + + int get_value(FieldUnit eDestUnit) const + { + return convert_value_to(m_xSpinButton->get_value(), eDestUnit); + } + + // typically you only need to call this if set_text (e.g. with "") was + // previously called to display some arbitrary text instead of the + // formatted value and now you want to show it as formatted again + void reformat() { spin_button_output(*m_xSpinButton); } + + void set_range(int min, int max, FieldUnit eValueUnit) + { + min = convert_value_from(min, eValueUnit); + max = convert_value_from(max, eValueUnit); + m_xSpinButton->set_range(min, max); + update_width_chars(); + } + + void get_range(int& min, int& max, FieldUnit eDestUnit) const + { + m_xSpinButton->get_range(min, max); + min = convert_value_to(min, eDestUnit); + max = convert_value_to(max, eDestUnit); + } + + void set_min(int min, FieldUnit eValueUnit) + { + int dummy, max; + get_range(dummy, max, eValueUnit); + set_range(min, max, eValueUnit); + } + + void set_max(int max, FieldUnit eValueUnit) + { + int min, dummy; + get_range(min, dummy, eValueUnit); + set_range(min, max, eValueUnit); + } + + int get_min(FieldUnit eValueUnit) const + { + int min, dummy; + get_range(min, dummy, eValueUnit); + return min; + } + + int get_max(FieldUnit eValueUnit) const + { + int dummy, max; + get_range(dummy, max, eValueUnit); + return max; + } + + void set_increments(int step, int page, FieldUnit eValueUnit) + { + step = convert_value_from(step, eValueUnit); + page = convert_value_from(page, eValueUnit); + m_xSpinButton->set_increments(step, page); + } + + void get_increments(int& step, int& page, FieldUnit eDestUnit) const + { + m_xSpinButton->get_increments(step, page); + step = convert_value_to(step, eDestUnit); + page = convert_value_to(page, eDestUnit); + } + + void connect_value_changed(const Link<MetricSpinButton&, void>& rLink) + { + m_aValueChangedHdl = rLink; + } + + int normalize(int nValue) const { return m_xSpinButton->normalize(nValue); } + int denormalize(int nValue) const { return m_xSpinButton->denormalize(nValue); } + void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); } + bool get_sensitive() const { return m_xSpinButton->get_sensitive(); } + bool get_visible() const { return m_xSpinButton->get_visible(); } + void grab_focus() { m_xSpinButton->grab_focus(); } + bool has_focus() const { return m_xSpinButton->has_focus(); } + void show() { m_xSpinButton->show(); } + void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); } + void hide() { m_xSpinButton->hide(); } + void set_digits(unsigned int digits); + void set_accessible_name(const OUString& rName) { m_xSpinButton->set_accessible_name(rName); } + unsigned int get_digits() const { return m_xSpinButton->get_digits(); } + void save_value() { m_xSpinButton->save_value(); } + bool get_value_changed_from_saved() const + { + return m_xSpinButton->get_value_changed_from_saved(); + } + void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); } + OUString get_text() const { return m_xSpinButton->get_text(); } + void set_size_request(int nWidth, int nHeight) + { + m_xSpinButton->set_size_request(nWidth, nHeight); + } + Size get_size_request() const { return m_xSpinButton->get_size_request(); } + Size get_preferred_size() const { return m_xSpinButton->get_preferred_size(); } + void connect_focus_in(const Link<Widget&, void>& rLink) + { + m_xSpinButton->connect_focus_in(rLink); + } + void connect_focus_out(const Link<Widget&, void>& rLink) + { + m_xSpinButton->connect_focus_out(rLink); + } + OString get_buildable_name() { return m_xSpinButton->get_buildable_name(); } + void set_help_id(const OString& rName) { m_xSpinButton->set_help_id(rName); } + void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } + // set the width of the underlying widget in characters, this setting is + // invalidated when changing the units, range or digits, so to have effect + // must come after changing those values + void set_width_chars(int nChars) { m_xSpinButton->set_width_chars(nChars); } + weld::SpinButton& get_widget() { return *m_xSpinButton; } +}; + +class VCL_DLLPUBLIC TimeSpinButton final +{ + TimeFieldFormat m_eFormat; + std::unique_ptr<weld::SpinButton> m_xSpinButton; + Link<TimeSpinButton&, void> m_aValueChangedHdl; + + DECL_LINK(spin_button_value_changed, weld::SpinButton&, void); + DECL_LINK(spin_button_output, weld::SpinButton&, void); + DECL_LINK(spin_button_input, int* result, bool); + DECL_LINK(spin_button_cursor_position, weld::Entry&, void); + + void signal_value_changed() { m_aValueChangedHdl.Call(*this); } + + static tools::Time ConvertValue(int nValue); + static int ConvertValue(const tools::Time& rTime); + OUString format_number(int nValue) const; + void update_width_chars(); + +public: + TimeSpinButton(std::unique_ptr<SpinButton> pSpinButton, TimeFieldFormat eFormat) + : m_eFormat(eFormat) + , m_xSpinButton(std::move(pSpinButton)) + { + update_width_chars(); + m_xSpinButton->connect_output(LINK(this, TimeSpinButton, spin_button_output)); + m_xSpinButton->connect_input(LINK(this, TimeSpinButton, spin_button_input)); + m_xSpinButton->connect_value_changed(LINK(this, TimeSpinButton, spin_button_value_changed)); + m_xSpinButton->connect_cursor_position( + LINK(this, TimeSpinButton, spin_button_cursor_position)); + spin_button_output(*m_xSpinButton); + } + + void set_value(const tools::Time& rTime) { m_xSpinButton->set_value(ConvertValue(rTime)); } + + tools::Time get_value() const { return ConvertValue(m_xSpinButton->get_value()); } + + void connect_value_changed(const Link<TimeSpinButton&, void>& rLink) + { + m_aValueChangedHdl = rLink; + } + + void set_sensitive(bool sensitive) { m_xSpinButton->set_sensitive(sensitive); } + bool get_sensitive() const { return m_xSpinButton->get_sensitive(); } + void set_visible(bool bShow) { m_xSpinButton->set_visible(bShow); } + bool get_visible() const { return m_xSpinButton->get_visible(); } + void grab_focus() { m_xSpinButton->grab_focus(); } + bool has_focus() const { return m_xSpinButton->has_focus(); } + void show() { m_xSpinButton->show(); } + void hide() { m_xSpinButton->hide(); } + void save_value() { m_xSpinButton->save_value(); } + bool get_value_changed_from_saved() const + { + return m_xSpinButton->get_value_changed_from_saved(); + } + void set_position(int nCursorPos) { m_xSpinButton->set_position(nCursorPos); } + void set_text(const OUString& rText) { m_xSpinButton->set_text(rText); } + OUString get_text() const { return m_xSpinButton->get_text(); } + void connect_focus_in(const Link<Widget&, void>& rLink) + { + m_xSpinButton->connect_focus_in(rLink); + } + void connect_focus_out(const Link<Widget&, void>& rLink) + { + m_xSpinButton->connect_focus_out(rLink); + } + weld::SpinButton& get_widget() { return *m_xSpinButton; } +}; + +class VCL_DLLPUBLIC Label : virtual public Widget +{ +public: + virtual void set_label(const OUString& rText) = 0; + virtual OUString get_label() const = 0; + virtual void set_mnemonic_widget(Widget* pTarget) = 0; + virtual void set_message_type(EntryMessageType eType) = 0; + // font size is in points, not pixels, e.g. see Window::[G]etPointFont + virtual void set_font(const vcl::Font& rFont) = 0; +}; + +class VCL_DLLPUBLIC TextView : virtual public Container +{ +private: + OUString m_sSavedValue; + +protected: + Link<TextView&, void> m_aChangeHdl; + Link<TextView&, void> m_aVChangeHdl; + Link<TextView&, void> m_aCursorPositionHdl; + + void signal_changed() { m_aChangeHdl.Call(*this); } + void signal_cursor_position() { m_aCursorPositionHdl.Call(*this); } + void signal_vadjustment_changed() { m_aVChangeHdl.Call(*this); } + +public: + virtual void set_text(const OUString& rText) = 0; + virtual OUString get_text() const = 0; + virtual void select_region(int nStartPos, int nEndPos) = 0; + virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0; + virtual void replace_selection(const OUString& rText) = 0; + virtual void set_editable(bool bEditable) = 0; + virtual void set_monospace(bool bMonospace) = 0; + int get_height_rows(int nRows) const + { + //can improve this if needed + return get_text_height() * nRows; + } + + void save_value() { m_sSavedValue = get_text(); } + bool get_value_changed_from_saved() const { return m_sSavedValue != get_text(); } + + void connect_changed(const Link<TextView&, void>& rLink) { m_aChangeHdl = rLink; } + virtual void connect_cursor_position(const Link<TextView&, void>& rLink) + { + m_aCursorPositionHdl = rLink; + } + + virtual int vadjustment_get_value() const = 0; + virtual int vadjustment_get_upper() const = 0; + virtual int vadjustment_get_lower() const = 0; + virtual int vadjustment_get_page_size() const = 0; + virtual void vadjustment_set_value(int value) = 0; + void connect_vadjustment_changed(const Link<TextView&, void>& rLink) { m_aVChangeHdl = rLink; } +}; + +class VCL_DLLPUBLIC Expander : virtual public Container +{ +protected: + Link<Expander&, void> m_aExpandedHdl; + + void signal_expanded() { m_aExpandedHdl.Call(*this); } + +public: + virtual bool get_expanded() const = 0; + virtual void set_expanded(bool bExpand) = 0; + + void connect_expanded(const Link<Expander&, void>& rLink) { m_aExpandedHdl = rLink; } +}; + +class VCL_DLLPUBLIC DrawingArea : virtual public Widget +{ +public: + typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> draw_args; + +protected: + Link<draw_args, void> m_aDrawHdl; + Link<Widget&, void> m_aStyleUpdatedHdl; + Link<const CommandEvent&, bool> m_aCommandHdl; + Link<Widget&, tools::Rectangle> m_aGetFocusRectHdl; + Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl; + // if handler returns true, drag is disallowed + Link<DrawingArea&, bool> m_aDragBeginHdl; + // return position of cursor, fill OUString& with surrounding text + Link<OUString&, int> m_aGetSurroundingHdl; + // attempt to delete the range, return true if successful + Link<const Selection&, bool> m_aDeleteSurroundingHdl; + + OUString signal_query_tooltip(tools::Rectangle& rHelpArea) + { + return m_aQueryTooltipHdl.Call(rHelpArea); + } + + int signal_im_context_get_surrounding(OUString& rSurroundingText) + { + if (!m_aGetSurroundingHdl.IsSet()) + return -1; + return m_aGetSurroundingHdl.Call(rSurroundingText); + } + + bool signal_im_context_delete_surrounding(const Selection& rRange) + { + return m_aDeleteSurroundingHdl.Call(rRange); + } + +public: + void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; } + void connect_style_updated(const Link<Widget&, void>& rLink) { m_aStyleUpdatedHdl = rLink; } + void connect_command(const Link<const CommandEvent&, bool>& rLink) { m_aCommandHdl = rLink; } + void connect_focus_rect(const Link<Widget&, tools::Rectangle>& rLink) + { + m_aGetFocusRectHdl = rLink; + } + void connect_query_tooltip(const Link<tools::Rectangle&, OUString>& rLink) + { + m_aQueryTooltipHdl = rLink; + } + void connect_drag_begin(const Link<DrawingArea&, bool>& rLink) { m_aDragBeginHdl = rLink; } + void connect_im_context_get_surrounding(const Link<OUString&, int>& rLink) + { + m_aGetSurroundingHdl = rLink; + } + void connect_im_context_delete_surrounding(const Link<const Selection&, bool>& rLink) + { + m_aDeleteSurroundingHdl = rLink; + } + virtual void queue_draw() = 0; + virtual void queue_draw_area(int x, int y, int width, int height) = 0; + virtual void queue_resize() = 0; + + virtual void enable_drag_source(rtl::Reference<TransferDataContainer>& rTransferrable, + sal_uInt8 eDNDConstants) + = 0; + + virtual void set_cursor(PointerStyle ePointerStyle) = 0; + + virtual void set_input_context(const InputContext& rInputContext) = 0; + virtual void im_context_set_cursor_location(const tools::Rectangle& rCursorRect, + int nExtTextInputWidth) + = 0; + + // use return here just to generate matching VirtualDevices + virtual OutputDevice& get_ref_device() = 0; + + virtual a11yref get_accessible_parent() = 0; + virtual a11yrelationset get_accessible_relation_set() = 0; + virtual Point get_accessible_location() = 0; +}; + +class VCL_DLLPUBLIC Menu +{ +protected: + Link<const OString&, void> m_aActivateHdl; + + void signal_activate(const OString& rIdent) { m_aActivateHdl.Call(rIdent); } + +public: + virtual OString popup_at_rect(weld::Widget* pParent, const tools::Rectangle& rRect) = 0; + + void connect_activate(const Link<const OString&, void>& rLink) { m_aActivateHdl = rLink; } + + virtual void set_sensitive(const OString& rIdent, bool bSensitive) = 0; + virtual void set_label(const OString& rIdent, const OUString& rLabel) = 0; + virtual OUString get_label(const OString& rIdent) const = 0; + virtual void set_active(const OString& rIdent, bool bActive) = 0; + virtual bool get_active(const OString& rIdent) const = 0; + virtual void set_visible(const OString& rIdent, bool bVisible) = 0; + + virtual void insert(int pos, const OUString& rId, const OUString& rStr, + const OUString* pIconName, VirtualDevice* pImageSurface, + TriState eCheckRadioFalse) + = 0; + + virtual void remove(const OString& rId) = 0; + + virtual void clear() = 0; + + virtual void insert_separator(int pos, const OUString& rId) = 0; + void append_separator(const OUString& rId) { insert_separator(-1, rId); } + + void append(const OUString& rId, const OUString& rStr) + { + insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_INDET); + } + void append_check(const OUString& rId, const OUString& rStr) + { + insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_TRUE); + } + void append_radio(const OUString& rId, const OUString& rStr) + { + insert(-1, rId, rStr, nullptr, nullptr, TRISTATE_FALSE); + } + void append(const OUString& rId, const OUString& rStr, const OUString& rImage) + { + insert(-1, rId, rStr, &rImage, nullptr, TRISTATE_INDET); + } + void append(const OUString& rId, const OUString& rStr, VirtualDevice& rImage) + { + insert(-1, rId, rStr, nullptr, &rImage, TRISTATE_INDET); + } + + // return the number of toplevel nodes + virtual int n_children() const = 0; + + virtual ~Menu() {} +}; + +class VCL_DLLPUBLIC Toolbar : virtual public Widget +{ +protected: + Link<const OString&, void> m_aClickHdl; + Link<const OString&, void> m_aToggleMenuHdl; + + void signal_clicked(const OString& rIdent) { m_aClickHdl.Call(rIdent); } + void signal_toggle_menu(const OString& rIdent) { m_aToggleMenuHdl.Call(rIdent); } + +public: + virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) = 0; + virtual bool get_item_sensitive(const OString& rIdent) const = 0; + virtual void set_item_active(const OString& rIdent, bool bActive) = 0; + virtual bool get_item_active(const OString& rIdent) const = 0; + virtual void set_menu_item_active(const OString& rIdent, bool bActive) = 0; + virtual bool get_menu_item_active(const OString& rIdent) const = 0; + virtual void set_item_menu(const OString& rIdent, weld::Menu* pMenu) = 0; + virtual void set_item_popover(const OString& rIdent, weld::Widget* pPopover) = 0; + virtual void set_item_visible(const OString& rIdent, bool bVisible) = 0; + virtual void set_item_help_id(const OString& rIdent, const OString& rHelpId) = 0; + virtual bool get_item_visible(const OString& rIdent) const = 0; + virtual void set_item_label(const OString& rIdent, const OUString& rLabel) = 0; + virtual OUString get_item_label(const OString& rIdent) const = 0; + virtual void set_item_tooltip_text(const OString& rIdent, const OUString& rTip) = 0; + virtual OUString get_item_tooltip_text(const OString& rIdent) const = 0; + virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) = 0; + virtual void set_item_image(const OString& rIdent, + const css::uno::Reference<css::graphic::XGraphic>& rIcon) + = 0; + virtual void set_item_image(const OString& rIdent, VirtualDevice* pDevice) = 0; + + virtual void insert_separator(int pos, const OUString& rId) = 0; + void append_separator(const OUString& rId) { insert_separator(-1, rId); } + + virtual int get_n_items() const = 0; + virtual OString get_item_ident(int nIndex) const = 0; + virtual void set_item_ident(int nIndex, const OString& rIdent) = 0; + virtual void set_item_label(int nIndex, const OUString& rLabel) = 0; + virtual void set_item_image(int nIndex, + const css::uno::Reference<css::graphic::XGraphic>& rIcon) + = 0; + virtual void set_item_tooltip_text(int nIndex, const OUString& rTip) = 0; + + virtual vcl::ImageType get_icon_size() const = 0; + virtual void set_icon_size(vcl::ImageType eType) = 0; + + // return what modifiers are held + virtual sal_uInt16 get_modifier_state() const = 0; + + // This function returns the position a new item should be inserted if dnd + // is dropped at rPoint + virtual int get_drop_index(const Point& rPoint) const = 0; + + void connect_clicked(const Link<const OString&, void>& rLink) { m_aClickHdl = rLink; } + void connect_menu_toggled(const Link<const OString&, void>& rLink) { m_aToggleMenuHdl = rLink; } +}; + +class VCL_DLLPUBLIC SizeGroup +{ +public: + virtual void add_widget(weld::Widget* pWidget) = 0; + // the default mode is VclSizeGroupMode::Horizontal + virtual void set_mode(VclSizeGroupMode eMode) = 0; + virtual ~SizeGroup() {} +}; + +class VCL_DLLPUBLIC Builder +{ +public: + virtual std::unique_ptr<MessageDialog> weld_message_dialog(const OString& id, + bool bTakeOwnership = true) + = 0; + virtual std::unique_ptr<Dialog> weld_dialog(const OString& id, bool bTakeOwnership = true) = 0; + virtual std::unique_ptr<Assistant> weld_assistant(const OString& id, bool bTakeOwnership = true) + = 0; + virtual std::unique_ptr<Window> weld_window(const OString& id, bool bTakeOwnership = true) = 0; + virtual std::unique_ptr<Widget> weld_widget(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Container> weld_container(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Box> weld_box(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Paned> weld_paned(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Button> weld_button(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<MenuButton> weld_menu_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Frame> weld_frame(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<ScrolledWindow> weld_scrolled_window(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Notebook> weld_notebook(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<ToggleButton> weld_toggle_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<RadioButton> weld_radio_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<CheckButton> weld_check_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<LinkButton> weld_link_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<SpinButton> weld_spin_button(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<MetricSpinButton> + weld_metric_spin_button(const OString& id, FieldUnit eUnit, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<FormattedSpinButton> + weld_formatted_spin_button(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<TimeSpinButton> + weld_time_spin_button(const OString& id, TimeFieldFormat eFormat, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<ComboBox> weld_combo_box(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<TreeView> weld_tree_view(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<IconView> weld_icon_view(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Label> weld_label(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<TextView> weld_text_view(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Expander> weld_expander(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Entry> weld_entry(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Scale> weld_scale(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<ProgressBar> weld_progress_bar(const OString& id, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Spinner> weld_spinner(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Image> weld_image(const OString& id, bool bTakeOwnership = false) = 0; + virtual std::unique_ptr<Calendar> weld_calendar(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<DrawingArea> + weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, + FactoryFunction pUITestFactoryFunction = nullptr, void* pUserData = nullptr, + bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<EntryTreeView> + weld_entry_tree_view(const OString& containerid, const OString& entryid, + const OString& treeviewid, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<Menu> weld_menu(const OString& id, bool bTakeOwnership = true) = 0; + virtual std::unique_ptr<Toolbar> weld_toolbar(const OString& id, bool bTakeOwnership = false) + = 0; + virtual std::unique_ptr<SizeGroup> create_size_group() = 0; + /* return a Dialog suitable to take a screenshot of containing the contents of the .ui file. + + If the toplevel element is a dialog, that will be returned + If the toplevel is not a dialog, a dialog will be created and the contents of the .ui + inserted into it + */ + virtual std::unique_ptr<Window> create_screenshot_window() = 0; + virtual ~Builder() {} +}; + +class VCL_DLLPUBLIC DialogController : public std::enable_shared_from_this<DialogController> +{ +public: + virtual Dialog* getDialog() = 0; + const Dialog* getConstDialog() const + { + return const_cast<DialogController*>(this)->getDialog(); + } + virtual short run() { return getDialog()->run(); } + static bool runAsync(const std::shared_ptr<DialogController>& rController, + const std::function<void(sal_Int32)>&); + void set_title(const OUString& rTitle) { getDialog()->set_title(rTitle); } + OUString get_title() const { return getConstDialog()->get_title(); } + void set_help_id(const OString& rHelpId) { getDialog()->set_help_id(rHelpId); } + OString get_help_id() const { return getConstDialog()->get_help_id(); } + void response(int nResponse) { getDialog()->response(nResponse); } + virtual ~DialogController() COVERITY_NOEXCEPT_FALSE; +}; + +class VCL_DLLPUBLIC GenericDialogController : public DialogController +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + std::shared_ptr<weld::Dialog> m_xDialog; + +public: + GenericDialogController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId, bool bMobile = false); + virtual Dialog* getDialog() override; + virtual ~GenericDialogController() COVERITY_NOEXCEPT_FALSE override; +}; + +class VCL_DLLPUBLIC MessageDialogController : public DialogController +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::MessageDialog> m_xDialog; + std::unique_ptr<weld::Container> m_xContentArea; + std::unique_ptr<weld::Widget> m_xRelocate; + std::unique_ptr<weld::Container> m_xOrigParent; + +public: + /* @param rRelocateId - optional argument of the name of a widget in the .ui file + which should be relocated into the content area of the dialog. + + e.g. a checkbox for a "Never show this again" option. + + This results in the named widget relocating to the same container + as the messages. This enables aligning the extra widget with the + message labels in the content area container which doesn't + explicitly exist in the ui description, but is only implied. + */ + MessageDialogController(weld::Widget* pParent, const OUString& rUIFile, + const OString& rDialogId, const OString& rRelocateId = OString()); + virtual Dialog* getDialog() override; + virtual ~MessageDialogController() override; + void set_primary_text(const OUString& rText) { m_xDialog->set_primary_text(rText); } + OUString get_primary_text() const { return m_xDialog->get_primary_text(); } + void set_default_response(int nResponse) { m_xDialog->set_default_response(nResponse); } +}; + +class VCL_DLLPUBLIC AssistantController : public DialogController +{ +protected: + std::unique_ptr<weld::Builder> m_xBuilder; + std::unique_ptr<weld::Assistant> m_xAssistant; + +public: + AssistantController(weld::Widget* pParent, const OUString& rUIFile, const OString& rDialogId); + virtual Dialog* getDialog() override; + virtual ~AssistantController() override; +}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx new file mode 100644 index 000000000..90a8a20a4 --- /dev/null +++ b/include/vcl/weldutils.hxx @@ -0,0 +1,168 @@ +/* -*- 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_WELDUTILS_HXX +#define INCLUDED_VCL_WELDUTILS_HXX + +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <comphelper/interfacecontainer2.hxx> +#include <cppuhelper/compbase.hxx> +#include <tools/link.hxx> +#include <vcl/dllapi.h> +#include <vcl/weld.hxx> + +namespace weld +{ +typedef cppu::WeakComponentImplHelper<css::awt::XWindow> TransportAsXWindow_Base; + +class VCL_DLLPUBLIC TransportAsXWindow : public TransportAsXWindow_Base +{ +private: + osl::Mutex m_aHelperMtx; + weld::Widget* m_pWeldWidget; + weld::Builder* m_pWeldWidgetBuilder; + + comphelper::OInterfaceContainerHelper2 m_aWindowListeners; + comphelper::OInterfaceContainerHelper2 m_aKeyListeners; + comphelper::OInterfaceContainerHelper2 m_aFocusListeners; + comphelper::OInterfaceContainerHelper2 m_aMouseListeners; + comphelper::OInterfaceContainerHelper2 m_aMotionListeners; + comphelper::OInterfaceContainerHelper2 m_aPaintListeners; + +public: + TransportAsXWindow(weld::Widget* pWeldWidget, weld::Builder* pWeldWidgetBuilder = nullptr) + : TransportAsXWindow_Base(m_aHelperMtx) + , m_pWeldWidget(pWeldWidget) + , m_pWeldWidgetBuilder(pWeldWidgetBuilder) + , m_aWindowListeners(m_aHelperMtx) + , m_aKeyListeners(m_aHelperMtx) + , m_aFocusListeners(m_aHelperMtx) + , m_aMouseListeners(m_aHelperMtx) + , m_aMotionListeners(m_aHelperMtx) + , m_aPaintListeners(m_aHelperMtx) + { + } + + weld::Widget* getWidget() const { return m_pWeldWidget; } + + weld::Builder* getBuilder() const { return m_pWeldWidgetBuilder; } + + virtual void clear() + { + m_pWeldWidget = nullptr; + m_pWeldWidgetBuilder = nullptr; + } + + // css::awt::XWindow + void SAL_CALL setPosSize(sal_Int32, sal_Int32, sal_Int32, sal_Int32, sal_Int16) override + { + throw css::uno::RuntimeException("not implemented"); + } + + css::awt::Rectangle SAL_CALL getPosSize() override + { + throw css::uno::RuntimeException("not implemented"); + } + + void SAL_CALL setVisible(sal_Bool bVisible) override { m_pWeldWidget->set_visible(bVisible); } + + void SAL_CALL setEnable(sal_Bool bSensitive) override + { + m_pWeldWidget->set_sensitive(bSensitive); + } + + void SAL_CALL setFocus() override { m_pWeldWidget->grab_focus(); } + + void SAL_CALL + addWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override + { + m_aWindowListeners.addInterface(rListener); + } + + void SAL_CALL + removeWindowListener(const css::uno::Reference<css::awt::XWindowListener>& rListener) override + { + m_aWindowListeners.removeInterface(rListener); + } + + void SAL_CALL + addFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override + { + m_aFocusListeners.addInterface(rListener); + } + + void SAL_CALL + removeFocusListener(const css::uno::Reference<css::awt::XFocusListener>& rListener) override + { + m_aFocusListeners.removeInterface(rListener); + } + + void SAL_CALL + addKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override + { + m_aKeyListeners.addInterface(rListener); + } + + void SAL_CALL + removeKeyListener(const css::uno::Reference<css::awt::XKeyListener>& rListener) override + { + m_aKeyListeners.removeInterface(rListener); + } + + void SAL_CALL + addMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override + { + m_aMouseListeners.addInterface(rListener); + } + + void SAL_CALL + removeMouseListener(const css::uno::Reference<css::awt::XMouseListener>& rListener) override + { + m_aMouseListeners.removeInterface(rListener); + } + + void SAL_CALL addMouseMotionListener( + const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override + { + m_aMotionListeners.addInterface(rListener); + } + + void SAL_CALL removeMouseMotionListener( + const css::uno::Reference<css::awt::XMouseMotionListener>& rListener) override + { + m_aMotionListeners.removeInterface(rListener); + } + + void SAL_CALL + addPaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override + { + m_aPaintListeners.addInterface(rListener); + } + + void SAL_CALL + removePaintListener(const css::uno::Reference<css::awt::XPaintListener>& rListener) override + { + m_aPaintListeners.removeInterface(rListener); + } +}; + +// get the row the iterator is on +VCL_DLLPUBLIC size_t GetAbsPos(const weld::TreeView& rTreeView, const weld::TreeIter& rIter); + +// an entry is visible if all parents are expanded +VCL_DLLPUBLIC bool IsEntryVisible(const weld::TreeView& rTreeView, const weld::TreeIter& rIter); + +// A Parent's Children are turned into Children of the Parent which comes next in hierarchy +VCL_DLLPUBLIC void RemoveParentKeepChildren(weld::TreeView& rTreeView, weld::TreeIter& rParent); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx new file mode 100644 index 000000000..8c3dc737c --- /dev/null +++ b/include/vcl/window.hxx @@ -0,0 +1,1587 @@ +/* -*- 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_WINDOW_HXX +#define INCLUDED_VCL_WINDOW_HXX + +#include <tools/solar.h> +#include <vcl/dllapi.h> +#include <vcl/outdev.hxx> +#include <tools/link.hxx> +#include <tools/wintypes.hxx> +#include <vcl/vclenum.hxx> +#include <vcl/keycodes.hxx> +#include <vcl/region.hxx> +#include <vcl/uitest/factory.hxx> +#include <vcl/IDialogRenderable.hxx> +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <memory> + +#include <boost/property_tree/ptree_fwd.hpp> + +class VirtualDevice; +struct ImplSVEvent; +struct ImplWinData; +struct ImplFrameData; +struct ImplCalcToTopData; +struct SystemEnvData; +struct SystemParentData; +class ImplBorderWindow; +class Timer; +class DockingManager; +class ScrollBar; +class FixedText; +class MouseEvent; +class KeyEvent; +class CommandEvent; +class TrackingEvent; +class HelpEvent; +class DataChangedEvent; +class VclSimpleEvent; +class NotifyEvent; +class SystemWindow; +class SalFrame; +class MenuFloatingWindow; +class VCLXWindow; +class VclWindowEvent; +class AllSettings; +class InputContext; +enum class ImplPaintFlags; +enum class VclEventId; +enum class PointerStyle; + +namespace com::sun::star { + namespace accessibility { + struct AccessibleRelation; + class XAccessible; + } + namespace rendering { + class XCanvas; + class XSpriteCanvas; + } + namespace awt { + class XWindowPeer; + } + namespace uno { + class Any; + } + namespace datatransfer::clipboard { + class XClipboard; + } + namespace datatransfer::dnd { + class XDragGestureRecognizer; + class XDragSource; + class XDropTarget; + } +} + +namespace vcl { + struct ControlLayoutData; +} + +namespace svt { class PopupWindowControllerImpl; } + +namespace weld { class Window; } + +template<class T> class VclPtr; + +enum class TrackingEventFlags +{ + NONE = 0x0000, + Cancel = 0x0001, + Key = 0x0002, + Focus = 0x0004, + Repeat = 0x0100, + End = 0x1000, +}; +namespace o3tl +{ + template<> struct typed_flags<TrackingEventFlags> : is_typed_flags<TrackingEventFlags, 0x1107> {}; +} + + +// Type for GetWindow() +enum class GetWindowType +{ + Parent = 0, + FirstChild = 1, + LastChild = 2, + Prev = 3, + Next = 4, + FirstOverlap = 5, + Overlap = 7, + ParentOverlap = 8, + Client = 9, + RealParent = 10, + Frame = 11, + Border = 12, + FirstTopWindowChild = 13, + NextTopWindowSibling = 16, +}; + +// Flags for setPosSizePixel() +// These must match the definitions in css::awt::PosSize +enum class PosSizeFlags +{ + NONE = 0x0000, + X = 0x0001, + Y = 0x0002, + Width = 0x0004, + Height = 0x0008, + Pos = X | Y, + Size = Width | Height, + PosSize = Pos | Size, + All = PosSize, +}; + +namespace o3tl +{ + template<> struct typed_flags<PosSizeFlags> : is_typed_flags<PosSizeFlags, 0x000f> {}; +} + +// Flags for Show() +enum class ShowFlags +{ + NONE = 0x0000, + NoFocusChange = 0x0002, + NoActivate = 0x0004, + ForegroundTask = 0x0008, +}; +namespace o3tl +{ + template<> struct typed_flags<ShowFlags> : is_typed_flags<ShowFlags, 0x000e> {}; +} + +// Flags for SetZOrder() +enum class ZOrderFlags +{ + NONE = 0x0000, + Before = 0x0001, + Behind = 0x0002, + First = 0x0004, + Last = 0x0008, +}; +namespace o3tl +{ + template<> struct typed_flags<ZOrderFlags> : is_typed_flags<ZOrderFlags, 0x000f> {}; +} + +// Activate-Flags +enum class ActivateModeFlags +{ + NONE = 0, + GrabFocus = 0x0001, +}; +namespace o3tl +{ + template<> struct typed_flags<ActivateModeFlags> : is_typed_flags<ActivateModeFlags, 0x0001> {}; +} + +// ToTop-Flags +enum class ToTopFlags +{ + NONE = 0x0000, + RestoreWhenMin = 0x0001, + ForegroundTask = 0x0002, + NoGrabFocus = 0x0004, + GrabFocusOnly = 0x0008, +}; +namespace o3tl +{ + template<> struct typed_flags<ToTopFlags> : is_typed_flags<ToTopFlags, 0x000f> {}; +} + +// Flags for Invalidate +// must match css::awt::InvalidateStyle +enum class InvalidateFlags +{ + NONE = 0x0000, + Children = 0x0001, + NoChildren = 0x0002, + NoErase = 0x0004, + Update = 0x0008, + Transparent = 0x0010, + NoTransparent = 0x0020, + NoClipChildren = 0x4000, +}; +namespace o3tl +{ + template<> struct typed_flags<InvalidateFlags> : is_typed_flags<InvalidateFlags, 0x403f> {}; +} + +// Flags for Validate +enum class ValidateFlags +{ + NONE = 0x0000, + Children = 0x0001, + NoChildren = 0x0002 +}; +namespace o3tl +{ + template<> struct typed_flags<ValidateFlags> : is_typed_flags<ValidateFlags, 0x0003> {}; +} + +// Flags for Scroll +enum class ScrollFlags +{ + NONE = 0x0000, + Clip = 0x0001, + Children = 0x0002, + NoChildren = 0x0004, + UseClipRegion = 0x0008, + Update = 0x0010, +}; +namespace o3tl +{ + template<> struct typed_flags<ScrollFlags> : is_typed_flags<ScrollFlags, 0x001f> {}; +} + +// Flags for ParentClipMode +enum class ParentClipMode +{ + NONE = 0x0000, + Clip = 0x0001, + NoClip = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags<ParentClipMode> : is_typed_flags<ParentClipMode, 0x0003> {}; +} + +// Flags for ShowTracking() +enum class ShowTrackFlags { + NONE = 0x0000, + Small = 0x0001, + Big = 0x0002, + Split = 0x0003, + Object = 0x0004, + StyleMask = 0x000F, + TrackWindow = 0x1000, + Clip = 0x2000, +}; +namespace o3tl +{ + template<> struct typed_flags<ShowTrackFlags> : is_typed_flags<ShowTrackFlags, 0x300f> {}; +} + +// Flags for StartTracking() +enum class StartTrackingFlags +{ + NONE = 0x0001, + KeyMod = 0x0002, + ScrollRepeat = 0x0004, + ButtonRepeat = 0x0008, +}; + +namespace o3tl +{ + template<> struct typed_flags<StartTrackingFlags> : is_typed_flags<StartTrackingFlags, 0x000f> {}; +} + +// Flags for StartAutoScroll() +enum class StartAutoScrollFlags +{ + NONE = 0x0000, + Vert = 0x0001, + Horz = 0x0002, +}; +namespace o3tl +{ + template<> struct typed_flags<StartAutoScrollFlags> : is_typed_flags<StartAutoScrollFlags, 0x0003> {}; +} + +// Flags for StateChanged() +enum class StateChangedType : sal_uInt16 +{ + InitShow = 1, + Visible = 2, + UpdateMode = 3, + Enable = 4, + Text = 5, + Data = 7, + State = 8, + Style = 9, + Zoom = 10, + ControlFont = 13, + ControlForeground = 14, + ControlBackground = 15, + ReadOnly = 16, + Mirroring = 18, + Layout = 19, + ControlFocus = 20 +}; + +// GetFocusFlags +// must match constants in css:awt::FocusChangeReason +enum class GetFocusFlags +{ + NONE = 0x0000, + Tab = 0x0001, + CURSOR = 0x0002, // avoid name-clash with X11 #define + Mnemonic = 0x0004, + F6 = 0x0008, + Forward = 0x0010, + Backward = 0x0020, + Around = 0x0040, + UniqueMnemonic = 0x0100, + Init = 0x0200, + FloatWinPopupModeEndCancel = 0x0400, +}; +namespace o3tl +{ + template<> struct typed_flags<GetFocusFlags> : is_typed_flags<GetFocusFlags, 0x077f> {}; +} + + +// Flags for Draw() +enum class DrawFlags +{ + NONE = 0x0000, + Mono = 0x0001, + NoControls = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags<DrawFlags> : is_typed_flags<DrawFlags, 0x0005> {}; +} + +// DialogControl-Flags +enum class DialogControlFlags +{ + NONE = 0x0000, + Return = 0x0001, + WantFocus = 0x0002, + FloatWinPopupModeEndCancel = 0x0004, +}; +namespace o3tl +{ + template<> struct typed_flags<DialogControlFlags> : is_typed_flags<DialogControlFlags, 0x0007> {}; +} + +// EndExtTextInput() Flags +enum class EndExtTextInputFlags +{ + NONE = 0x0000, + Complete = 0x0001 +}; +namespace o3tl +{ + template<> struct typed_flags<EndExtTextInputFlags> : is_typed_flags<EndExtTextInputFlags, 0x0001> {}; +} + +#define IMPL_MINSIZE_BUTTON_WIDTH 70 +#define IMPL_MINSIZE_BUTTON_HEIGHT 22 +#define IMPL_EXTRA_BUTTON_WIDTH 18 +#define IMPL_EXTRA_BUTTON_HEIGHT 10 +#define IMPL_SEP_BUTTON_X 5 +#define IMPL_SEP_BUTTON_Y 5 +#define IMPL_MINSIZE_MSGBOX_WIDTH 150 +#define IMPL_DIALOG_OFFSET 5 +#define IMPL_DIALOG_BAR_OFFSET 3 +#define IMPL_MSGBOX_OFFSET_EXTRA_X 0 +#define IMPL_MSGBOX_OFFSET_EXTRA_Y 2 +#define IMPL_SEP_MSGBOX_IMAGE 8 + +// ImplGetDlgWindow() +enum class GetDlgWindowType +{ + Prev, Next, First +}; + + +#ifdef DBG_UTIL +const char* ImplDbgCheckWindow( const void* pObj ); +#endif + +namespace vcl { class Window; } +namespace vcl { class Cursor; } +class Dialog; +class Edit; +class WindowImpl; +class PaintHelper; +class VclSizeGroup; +class Application; +class WorkWindow; +class MessBox; +class MessageDialog; +class DockingWindow; +class FloatingWindow; +class GroupBox; +class PushButton; +class RadioButton; +class SystemChildWindow; +class ImplDockingWindowWrapper; +class ImplPopupFloatWin; +class LifecycleTest; + + +enum class WindowHitTest { + NONE = 0x0000, + Inside = 0x0001, + Transparent = 0x0002 +}; +namespace o3tl { + template<> struct typed_flags<WindowHitTest> : is_typed_flags<WindowHitTest, 0x0003> {}; +}; + + +enum class WindowExtendedStyle { + NONE = 0x0000, + Document = 0x0001, + DocModified = 0x0002, + /** + * This is a frame window that is requested to be hidden (not just "not yet + * shown"). + */ + DocHidden = 0x0004, +}; +namespace o3tl { + template<> struct typed_flags<WindowExtendedStyle> : is_typed_flags<WindowExtendedStyle, 0x0007> {}; +}; + +namespace vcl { + +class VCL_DLLPUBLIC RenderTools +{ +public: + // transparent background for selected or checked items in toolboxes etc. + // + selection Color with a text color complementing the selection background + // + rounded edge + static void DrawSelectionBackground(vcl::RenderContext& rRenderContext, vcl::Window const & rWindow, + const tools::Rectangle& rRect, sal_uInt16 nHighlight, + bool bChecked, bool bDrawBorder, bool bDrawExtBorderOnly, + Color* pSelectionTextColor = nullptr, long nCornerRadius = 0, + Color const * pPaintColor = nullptr); +}; + +class VCL_DLLPUBLIC Window : public ::OutputDevice +{ + friend class ::vcl::Cursor; + friend class ::OutputDevice; + friend class ::Application; + friend class ::SystemWindow; + friend class ::WorkWindow; + friend class ::Dialog; + friend class ::Edit; + friend class ::MessBox; + friend class ::MessageDialog; + friend class ::DockingWindow; + friend class ::FloatingWindow; + friend class ::GroupBox; + friend class ::PushButton; + friend class ::RadioButton; + friend class ::SystemChildWindow; + friend class ::ImplBorderWindow; + friend class ::PaintHelper; + friend class ::LifecycleTest; + + // TODO: improve missing functionality + // only required because of SetFloatingMode() + friend class ::ImplDockingWindowWrapper; + friend class ::ImplPopupFloatWin; + friend class ::MenuFloatingWindow; + + friend class ::svt::PopupWindowControllerImpl; + +private: + // NOTE: to remove many dependencies of other modules + // to this central file, all members are now hidden + // in the WindowImpl class and all inline functions + // were removed. + // (WindowImpl is a pImpl pattern) + + // Please do *not* add new members or inline functions to class Window, + // but use class WindowImpl instead + + std::unique_ptr<WindowImpl> mpWindowImpl; + +#ifdef DBG_UTIL + friend const char* ::ImplDbgCheckWindow( const void* pObj ); +#endif + +public: + + DECL_DLLPRIVATE_LINK( ImplHandlePaintHdl, Timer*, void ); + DECL_DLLPRIVATE_LINK( ImplGenerateMouseMoveHdl, void*, void ); + DECL_DLLPRIVATE_LINK( ImplTrackTimerHdl, Timer*, void ); + DECL_DLLPRIVATE_LINK( ImplAsyncFocusHdl, void*, void ); + DECL_DLLPRIVATE_LINK( ImplHandleResizeTimerHdl, Timer*, void ); + + + SAL_DLLPRIVATE static void ImplInitAppFontData( vcl::Window const * pWindow ); + + SAL_DLLPRIVATE vcl::Window* ImplGetFrameWindow() const; + weld::Window* GetFrameWeld() const; + vcl::Window* GetFrameWindow() const; + SalFrame* ImplGetFrame() const; + SAL_DLLPRIVATE ImplFrameData* ImplGetFrameData(); + + vcl::Window* ImplGetWindow() const; ///< if this is a proxy return the client, otherwise itself + SAL_DLLPRIVATE ImplWinData* ImplGetWinData() const; + SAL_DLLPRIVATE vcl::Window* ImplGetClientWindow() const; + SAL_DLLPRIVATE vcl::Window* ImplGetDlgWindow( sal_uInt16 n, GetDlgWindowType nType, sal_uInt16 nStart = 0, sal_uInt16 nEnd = 0xFFFF, sal_uInt16* pIndex = nullptr ); + SAL_DLLPRIVATE vcl::Window* ImplGetParent() const; + SAL_DLLPRIVATE vcl::Window* ImplFindWindow( const Point& rFramePos ); + + SAL_DLLPRIVATE void ImplInvalidateFrameRegion( const vcl::Region* pRegion, InvalidateFlags nFlags ); + SAL_DLLPRIVATE void ImplInvalidateOverlapFrameRegion( const vcl::Region& rRegion ); + + SAL_DLLPRIVATE bool ImplSetClipFlag( bool bSysObjOnlySmaller = false ); + + SAL_DLLPRIVATE bool ImplIsWindowOrChild( const vcl::Window* pWindow, bool bSystemWindow = false ) const; + SAL_DLLPRIVATE bool ImplIsChild( const vcl::Window* pWindow, bool bSystemWindow = false ) const; + SAL_DLLPRIVATE bool ImplIsFloatingWindow() const; + SAL_DLLPRIVATE bool ImplIsPushButton() const; + SAL_DLLPRIVATE bool ImplIsSplitter() const; + SAL_DLLPRIVATE bool ImplIsOverlapWindow() const; + + SAL_DLLPRIVATE void ImplIsInTaskPaneList( bool mbIsInTaskList ); + + SAL_DLLPRIVATE WindowImpl* ImplGetWindowImpl() const { return mpWindowImpl.get(); } + + SAL_DLLPRIVATE Point ImplFrameToOutput( const Point& rPos ); + + SAL_DLLPRIVATE void ImplGrabFocus( GetFocusFlags nFlags ); + SAL_DLLPRIVATE void ImplGrabFocusToDocument( GetFocusFlags nFlags ); + SAL_DLLPRIVATE void ImplInvertFocus( const tools::Rectangle& rRect ); + + SAL_DLLPRIVATE PointerStyle ImplGetMousePointer() const; + SAL_DLLPRIVATE void ImplCallMouseMove( sal_uInt16 nMouseCode, bool bModChanged = false ); + SAL_DLLPRIVATE void ImplGenerateMouseMove(); + + SAL_DLLPRIVATE void ImplNotifyKeyMouseCommandEventListeners( NotifyEvent& rNEvt ); + SAL_DLLPRIVATE void ImplNotifyIconifiedState( bool bIconified ); + + SAL_DLLPRIVATE void ImplUpdateAll(); + + SAL_DLLPRIVATE void ImplControlFocus( GetFocusFlags nFlags = GetFocusFlags::NONE ); + + SAL_DLLPRIVATE void ImplMirrorFramePos( Point &pt ) const; + + SAL_DLLPRIVATE void ImplPosSizeWindow( long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags ); + + SAL_DLLPRIVATE void ImplCallResize(); + SAL_DLLPRIVATE void ImplCallMove(); + + void IncModalCount(); + void DecModalCount(); + + SAL_DLLPRIVATE static void ImplCalcSymbolRect( tools::Rectangle& rRect ); + +protected: + + /** This is intended to be used to clear any locally held references to other Window-subclass objects */ + virtual void dispose() override; + + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData ); + + SAL_DLLPRIVATE Point ImplOutputToFrame( const Point& rPos ); + + SAL_DLLPRIVATE void ImplInvalidateParentFrameRegion( vcl::Region& rRegion ); + SAL_DLLPRIVATE void ImplValidateFrameRegion( const vcl::Region* rRegion, ValidateFlags nFlags ); + SAL_DLLPRIVATE void ImplValidate(); + SAL_DLLPRIVATE void ImplMoveInvalidateRegion( const tools::Rectangle& rRect, long nHorzScroll, long nVertScroll, bool bChildren ); + SAL_DLLPRIVATE void ImplMoveAllInvalidateRegions( const tools::Rectangle& rRect, long nHorzScroll, long nVertScroll, bool bChildren ); + + SAL_DLLPRIVATE vcl::Window* ImplGetBorderWindow() const; + + SAL_DLLPRIVATE void ImplInvalidate( const vcl::Region* rRegion, InvalidateFlags nFlags ); + + virtual WindowHitTest ImplHitTest( const Point& rFramePos ); + + SAL_DLLPRIVATE void ImplSetMouseTransparent( bool bTransparent ); + + SAL_DLLPRIVATE void ImplScroll( const tools::Rectangle& rRect, long nHorzScroll, long nVertScroll, ScrollFlags nFlags ); + + SAL_DLLPRIVATE bool ImplSetClipFlagChildren( bool bSysObjOnlySmaller ); + SAL_DLLPRIVATE bool ImplSetClipFlagOverlapWindows( bool bSysObjOnlySmaller = false ); + + SAL_DLLPRIVATE void PushPaintHelper(PaintHelper* pHelper, vcl::RenderContext& rRenderContext); + SAL_DLLPRIVATE void PopPaintHelper(PaintHelper const * pHelper); + +private: + + SAL_DLLPRIVATE void ImplSetFrameParent( const vcl::Window* pParent ); + + SAL_DLLPRIVATE void ImplInsertWindow( vcl::Window* pParent ); + SAL_DLLPRIVATE void ImplRemoveWindow( bool bRemoveFrameData ); + + SAL_DLLPRIVATE SalGraphics* ImplGetFrameGraphics() const; + + SAL_DLLPRIVATE static void ImplCallFocusChangeActivate( vcl::Window* pNewOverlapWindow, vcl::Window* pOldOverlapWindow ); + SAL_DLLPRIVATE vcl::Window* ImplGetFirstOverlapWindow(); + SAL_DLLPRIVATE const vcl::Window* ImplGetFirstOverlapWindow() const; + + SAL_DLLPRIVATE bool ImplIsRealParentPath( const vcl::Window* pWindow ) const; + + SAL_DLLPRIVATE bool ImplTestMousePointerSet(); + + SAL_DLLPRIVATE void ImplResetReallyVisible(); + SAL_DLLPRIVATE void ImplSetReallyVisible(); + + SAL_DLLPRIVATE void ImplCallInitShow(); + + SAL_DLLPRIVATE void ImplInitResolutionSettings(); + + SAL_DLLPRIVATE void ImplPointToLogic(vcl::RenderContext const & rRenderContext, vcl::Font& rFont) const; + SAL_DLLPRIVATE void ImplLogicToPoint(vcl::RenderContext const & rRenderContext, vcl::Font& rFont) const; + + SAL_DLLPRIVATE bool ImplSysObjClip( const vcl::Region* pOldRegion ); + SAL_DLLPRIVATE void ImplUpdateSysObjChildrenClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjOverlapsClip(); + SAL_DLLPRIVATE void ImplUpdateSysObjClip(); + + SAL_DLLPRIVATE void ImplIntersectWindowClipRegion( vcl::Region& rRegion ); + SAL_DLLPRIVATE void ImplIntersectWindowRegion( vcl::Region& rRegion ); + SAL_DLLPRIVATE void ImplExcludeWindowRegion( vcl::Region& rRegion ); + SAL_DLLPRIVATE void ImplExcludeOverlapWindows( vcl::Region& rRegion ) const; + SAL_DLLPRIVATE void ImplExcludeOverlapWindows2( vcl::Region& rRegion ); + + SAL_DLLPRIVATE void ImplClipBoundaries( vcl::Region& rRegion, bool bThis, bool bOverlaps ); + SAL_DLLPRIVATE bool ImplClipChildren( vcl::Region& rRegion ) const; + SAL_DLLPRIVATE void ImplClipAllChildren( vcl::Region& rRegion ) const; + SAL_DLLPRIVATE void ImplClipSiblings( vcl::Region& rRegion ) const; + + SAL_DLLPRIVATE void ImplInitWinClipRegion(); + SAL_DLLPRIVATE void ImplInitWinChildClipRegion(); + SAL_DLLPRIVATE vcl::Region* ImplGetWinChildClipRegion(); + + SAL_DLLPRIVATE void ImplIntersectAndUnionOverlapWindows( const vcl::Region& rInterRegion, vcl::Region& rRegion ) const; + SAL_DLLPRIVATE void ImplIntersectAndUnionOverlapWindows2( const vcl::Region& rInterRegion, vcl::Region& rRegion ); + SAL_DLLPRIVATE void ImplCalcOverlapRegionOverlaps( const vcl::Region& rInterRegion, vcl::Region& rRegion ) const; + SAL_DLLPRIVATE void ImplCalcOverlapRegion( const tools::Rectangle& rSourceRect, vcl::Region& rRegion, + bool bChildren, bool bSiblings ); + + /** Invoke the actual painting. + + This function is kind of recursive - it may be called from the + PaintHelper destructor; and on the other hand it creates PaintHelper + that (when destructed) calls other ImplCallPaint()'s. + */ + SAL_DLLPRIVATE void ImplCallPaint(const vcl::Region* pRegion, ImplPaintFlags nPaintFlags); + + SAL_DLLPRIVATE void ImplCallOverlapPaint(); + + SAL_DLLPRIVATE void ImplUpdateWindowPtr( vcl::Window* pWindow ); + SAL_DLLPRIVATE void ImplUpdateWindowPtr(); + SAL_DLLPRIVATE void ImplUpdateOverlapWindowPtr( bool bNewFrame ); + + SAL_DLLPRIVATE bool ImplUpdatePos(); + SAL_DLLPRIVATE void ImplUpdateSysObjPos(); + + SAL_DLLPRIVATE void ImplUpdateGlobalSettings( AllSettings& rSettings, bool bCallHdl = true ) const; + + SAL_DLLPRIVATE void ImplToBottomChild(); + + SAL_DLLPRIVATE void ImplCalcToTop( ImplCalcToTopData* pPrevData ); + SAL_DLLPRIVATE void ImplToTop( ToTopFlags nFlags ); + SAL_DLLPRIVATE void ImplStartToTop( ToTopFlags nFlags ); + SAL_DLLPRIVATE void ImplFocusToTop( ToTopFlags nFlags, bool bReallyVisible ); + + SAL_DLLPRIVATE void ImplShowAllOverlaps(); + SAL_DLLPRIVATE void ImplHideAllOverlaps(); + + SAL_DLLPRIVATE bool ImplDlgCtrl( const KeyEvent& rKEvt, bool bKeyInput ); + SAL_DLLPRIVATE bool ImplHasDlgCtrl() const; + SAL_DLLPRIVATE void ImplDlgCtrlNextWindow(); + SAL_DLLPRIVATE void ImplDlgCtrlFocusChanged( vcl::Window* pWindow, bool bGetFocus ); + SAL_DLLPRIVATE vcl::Window* ImplFindDlgCtrlWindow( vcl::Window* pWindow ); + + SAL_DLLPRIVATE static void ImplNewInputContext(); + + SAL_DLLPRIVATE void ImplCallActivateListeners(vcl::Window*); + SAL_DLLPRIVATE void ImplCallDeactivateListeners(vcl::Window*); + + SAL_DLLPRIVATE static void ImplHandleScroll(ScrollBar* pHScrl, double nX, ScrollBar* pVScrl, double nY); + + SAL_DLLPRIVATE tools::Rectangle ImplOutputToUnmirroredAbsoluteScreenPixel( const tools::Rectangle& rRect ) const; + SAL_DLLPRIVATE long ImplGetUnmirroredOutOffX(); + + // retrieves the list of owner draw decorated windows for this window hierarchy + SAL_DLLPRIVATE ::std::vector<VclPtr<vcl::Window> >& ImplGetOwnerDrawList(); + + SAL_DLLPRIVATE vcl::Window* ImplGetTopmostFrameWindow(); + + SAL_DLLPRIVATE tools::Rectangle ImplGetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const; + + SAL_DLLPRIVATE bool ImplStopDnd(); + SAL_DLLPRIVATE void ImplStartDnd(); + + SAL_DLLPRIVATE void ImplPaintToDevice( ::OutputDevice* pTargetOutDev, const Point& rPos ); + + SAL_DLLPRIVATE css::uno::Reference< css::rendering::XCanvas > + ImplGetCanvas( bool bSpriteCanvas ) const; + +public: + virtual vcl::Region GetActiveClipRegion() const override; + virtual vcl::Region GetOutputBoundsClipRegion() const override; + +protected: + // Single argument ctors shall be explicit. + explicit Window( WindowType nType ); + + void SetCompoundControl( bool bCompound ); + + void CallEventListeners( VclEventId nEvent, void* pData = nullptr ); + static void FireVclEvent( VclSimpleEvent& rEvent ); + + virtual bool AcquireGraphics() const override; + virtual void ReleaseGraphics( bool bRelease = true ) override; + + virtual void InitClipRegion() override; + + void ImplClearFontData(bool bNewFontLists) override; + void ImplRefreshFontData(bool bNewFontLists) override; + void ImplInitMapModeObjects() override; + + // FIXME: this is a hack to workaround missing layout functionality + virtual void ImplAdjustNWFSizes(); + + virtual void CopyDeviceArea( SalTwoRect& aPosAry, bool bWindowInvalidate) override; + virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice* pSrcDev) const override; + virtual void DrawOutDevDirectProcess( const OutputDevice* pSrcDev, SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) override; + virtual void ClipToPaintRegion( tools::Rectangle& rDstRect ) override; + virtual bool UsePolyPolygonForComplexGradient() override; + + virtual void ApplySettings(vcl::RenderContext& rRenderContext); +public: + bool HasMirroredGraphics() const override; + +public: + // Single argument ctors shall be explicit. + explicit Window( vcl::Window* pParent, WinBits nStyle = 0 ); + + virtual ~Window() override; + + ::OutputDevice const* GetOutDev() const; + ::OutputDevice* GetOutDev(); + + Color GetBackgroundColor() const override; + + virtual void EnableRTL ( bool bEnable = true ) override; + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + virtual void PrePaint(vcl::RenderContext& rRenderContext); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); + virtual void PostPaint(vcl::RenderContext& rRenderContext); + + using OutputDevice::Erase; + void Erase(vcl::RenderContext& rRenderContext); + + virtual void Draw( ::OutputDevice* pDev, const Point& rPos, DrawFlags nFlags ); + virtual void Move(); + virtual void Resize(); + virtual void Activate(); + virtual void Deactivate(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void RequestHelp( const HelpEvent& rHEvt ); + virtual void Command( const CommandEvent& rCEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void StateChanged( StateChangedType nStateChange ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual bool PreNotify( NotifyEvent& rNEvt ); + virtual bool EventNotify( NotifyEvent& rNEvt ); + + // These methods call the relevant virtual method when not in/post dispose + void CompatGetFocus(); + void CompatLoseFocus(); + void CompatStateChanged( StateChangedType nStateChange ); + void CompatDataChanged( const DataChangedEvent& rDCEvt ); + bool CompatPreNotify( NotifyEvent& rNEvt ); + bool CompatNotify( NotifyEvent& rNEvt ); + + void AddEventListener( const Link<VclWindowEvent&,void>& rEventListener ); + void RemoveEventListener( const Link<VclWindowEvent&,void>& rEventListener ); + void AddChildEventListener( const Link<VclWindowEvent&,void>& rEventListener ); + void RemoveChildEventListener( const Link<VclWindowEvent&,void>& rEventListener ); + + ImplSVEvent * PostUserEvent( const Link<void*,void>& rLink, void* pCaller = nullptr, bool bReferenceLink = false ); + void RemoveUserEvent( ImplSVEvent * nUserEvent ); + + // returns the input language used for the last key stroke + // may be LANGUAGE_DONTKNOW if not supported by the OS + LanguageType GetInputLanguage() const; + + void SetStyle( WinBits nStyle ); + WinBits GetStyle() const; + WinBits GetPrevStyle() const; + void SetExtendedStyle( WindowExtendedStyle nExtendedStyle ); + WindowExtendedStyle GetExtendedStyle() const; + void SetType( WindowType nType ); + WindowType GetType() const; + bool IsSystemWindow() const; + bool IsDockingWindow() const; + bool IsDialog() const; + bool IsMenuFloatingWindow() const; + bool IsToolbarFloatingWindow() const; + bool IsTopWindow() const; + bool IsDisposed() const; + SystemWindow* GetSystemWindow() const; + + /// Can the widget derived from this Window do the double-buffering via RenderContext properly? + bool SupportsDoubleBuffering() const; + /// Enable/disable double-buffering of the frame window and all its children. + void RequestDoubleBuffering(bool bRequest); + + void EnableAllResize(); + + void SetBorderStyle( WindowBorderStyle nBorderStyle ); + WindowBorderStyle GetBorderStyle() const; + void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, + sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; + Size CalcWindowSize( const Size& rOutSz ) const; + Size CalcOutputSize( const Size& rWinSz ) const; + long CalcTitleWidth() const; + + void EnableClipSiblings( bool bClipSiblings = true ); + + void EnableChildTransparentMode( bool bEnable = true ); + bool IsChildTransparentModeEnabled() const; + + void SetMouseTransparent( bool bTransparent ); + bool IsMouseTransparent() const; + void SetPaintTransparent( bool bTransparent ); + bool IsPaintTransparent() const; + void SetDialogControlStart( bool bStart ); + bool IsDialogControlStart() const; + void SetDialogControlFlags( DialogControlFlags nFlags ); + DialogControlFlags GetDialogControlFlags() const; + + struct PointerState + { + sal_uLong mnState; // the button state + Point maPos; // mouse position in output coordinates + }; + PointerState GetPointerState(); + bool IsMouseOver() const; + + void SetInputContext( const InputContext& rInputContext ); + const InputContext& GetInputContext() const; + void PostExtTextInputEvent(VclEventId nType, const OUString& rText); + void EndExtTextInput(); + void SetCursorRect( const tools::Rectangle* pRect = nullptr, long nExtTextInputWidth = 0 ); + const tools::Rectangle* GetCursorRect() const; + long GetCursorExtTextInputWidth() const; + + void SetCompositionCharRect( const tools::Rectangle* pRect, long nCompositionLength, bool bVertical = false ); + + using ::OutputDevice::SetSettings; + virtual void SetSettings( const AllSettings& rSettings ) override; + void SetSettings( const AllSettings& rSettings, bool bChild ); + void UpdateSettings( const AllSettings& rSettings, bool bChild = false ); + void NotifyAllChildren( DataChangedEvent& rDCEvt ); + + void SetPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont); + vcl::Font GetPointFont(vcl::RenderContext const & rRenderContext) const; + void SetZoomedPointFont(vcl::RenderContext& rRenderContext, const vcl::Font& rFont); + long GetDrawPixel( ::OutputDevice const * pDev, long nPixels ) const; + vcl::Font GetDrawPixelFont( ::OutputDevice const * pDev ) const; + + void SetControlFont(); + void SetControlFont( const vcl::Font& rFont ); + vcl::Font GetControlFont() const; + bool IsControlFont() const; + void ApplyControlFont(vcl::RenderContext& rRenderContext, const vcl::Font& rDefaultFont); + + void SetControlForeground(); + void SetControlForeground(const Color& rColor); + const Color& GetControlForeground() const; + bool IsControlForeground() const; + void ApplyControlForeground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor); + + void SetControlBackground(); + void SetControlBackground( const Color& rColor ); + const Color& GetControlBackground() const; + bool IsControlBackground() const; + void ApplyControlBackground(vcl::RenderContext& rRenderContext, const Color& rDefaultColor); + + void SetParentClipMode( ParentClipMode nMode = ParentClipMode::NONE ); + ParentClipMode GetParentClipMode() const; + + void SetWindowRegionPixel(); + void SetWindowRegionPixel( const vcl::Region& rRegion ); + vcl::Region GetWindowClipRegionPixel() const; + vcl::Region GetPaintRegion() const; + bool IsInPaint() const; + // while IsInPaint returns true ExpandPaintClipRegion adds the + // submitted region to the paint clip region so you can + // paint additional parts of your window if necessary + void ExpandPaintClipRegion( const vcl::Region& rRegion ); + + void SetParent( vcl::Window* pNewParent ); + vcl::Window* GetParent() const; + // return the dialog we are contained in or NULL if un-contained + Dialog* GetParentDialog() const; + bool IsAncestorOf( const vcl::Window& rWindow ) const; + + void Show( bool bVisible = true, ShowFlags nFlags = ShowFlags::NONE ); + void Hide() { Show( false ); } + bool IsVisible() const; + bool IsReallyVisible() const; + bool IsReallyShown() const; + bool IsInInitShow() const; + + void Enable( bool bEnable = true, bool bChild = true ); + void Disable( bool bChild = true ) { Enable( false, bChild ); } + bool IsEnabled() const; + + void EnableInput( bool bEnable = true, bool bChild = true ); + void EnableInput( bool bEnable, const vcl::Window* pExcludeWindow ); + bool IsInputEnabled() const; + + /** Override <code>EnableInput</code>. This can be necessary due to other people + using EnableInput for whole window hierarchies. + + + <code>AlwaysEnableInput</code> and <code>AlwaysDisableInput</code> are + mutually exclusive; the last setter wins. + @param bAlways + sets always enabled flag + + @param bChild + if true children are recursively set to AlwaysEnableInput + */ + void AlwaysEnableInput( bool bAlways, bool bChild = true ); + /** returns the current AlwaysEnableInput state + @return + true if window is in AlwaysEnableInput state + */ + bool IsAlwaysEnableInput() const; + /** Override <code>EnableInput</code>, counterpart to AlwaysEnableInput. + Windows with AlwaysDisableInput will not get key events even if enabled + and input enabled.This can be necessary due to other people using EnableInput + for whole window hierarchies. + + <code>AlwaysEnableInput</code> and <code>AlwaysDisableInput</code> are + mutually exclusive; the last setter wins. + + @param bAlways + sets always disable flag + + @param bChild + if true children are recursively set to AlwaysDisableInput + */ + void AlwaysDisableInput( bool bAlways, bool bChild = true ); + + /** usually event handlers (see AddEventListener and AddChildEventListener) + are not called on disabled, modal or input disabled windows. There are however rare cases + in which one wants a Window or rather one of its Control subclasses to + not evaluate events but still react to those events externally. In these + rare cases call SetCallHandlersOnInputDisabled( true ) to have your handler + called anyway. + + Currently only mouse events get this special treatment. + + Use this sparingly, chances are if you want to use it you're working around + the real problem. + + @param bCall + Enable/Disable calling event handlers for this disabled, modal or input disabled window. + This call is implicitly done recursively for possible child windows. + */ + void SetCallHandlersOnInputDisabled( bool bCall ); + /** get state of SetCallHandlersOnInputDisabled + + @returns whether handlers are called regardless of input enabled state + */ + bool IsCallHandlersOnInputDisabled() const; + /** A window is in modal mode if one of its children or subchildren + is a running modal window (a modal dialog) + + @returns sal_True if a child or subchild is a running modal window + */ + bool IsInModalMode() const; + + void SetActivateMode( ActivateModeFlags nMode ); + ActivateModeFlags GetActivateMode() const; + + void ToTop( ToTopFlags nFlags = ToTopFlags::NONE ); + void SetZOrder( vcl::Window* pRefWindow, ZOrderFlags nFlags ); + void EnableAlwaysOnTop( bool bEnable = true ); + bool IsAlwaysOnTopEnabled() const; + + virtual void setPosSizePixel( long nX, long nY, + long nWidth, long nHeight, + PosSizeFlags nFlags = PosSizeFlags::All ); + virtual void SetPosPixel( const Point& rNewPos ); + virtual Point GetPosPixel() const; + virtual void SetSizePixel( const Size& rNewSize ); + virtual Size GetSizePixel() const; + virtual void SetPosSizePixel( const Point& rNewPos, + const Size& rNewSize ); + virtual void SetOutputSizePixel( const Size& rNewSize ); + bool IsDefaultPos() const; + bool IsDefaultSize() const; + Point GetOffsetPixelFrom(const vcl::Window& rWindow) const; + + // those conversion routines might deliver different results during UI mirroring + Point OutputToScreenPixel( const Point& rPos ) const; + Point ScreenToOutputPixel( const Point& rPos ) const; + // the normalized screen methods work independent from UI mirroring + Point OutputToNormalizedScreenPixel( const Point& rPos ) const; + Point NormalizedScreenToOutputPixel( const Point& rPos ) const; + Point OutputToAbsoluteScreenPixel( const Point& rPos ) const; + Point AbsoluteScreenToOutputPixel( const Point& rPos ) const; + tools::Rectangle GetDesktopRectPixel() const; + // window extents including border and decoration + tools::Rectangle GetWindowExtentsRelative( vcl::Window *pRelativeWindow ) const; + + bool IsScrollable() const; + virtual void Scroll( long nHorzScroll, long nVertScroll, + ScrollFlags nFlags = ScrollFlags::NONE ); + void Scroll( long nHorzScroll, long nVertScroll, + const tools::Rectangle& rRect, ScrollFlags nFlags = ScrollFlags::NONE ); + virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ); + virtual void Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE ); + virtual void Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE ); + /** + * Notification about some rectangle of the output device got invalidated.Used for the main + * document window. + * + * @param pRectangle If 0, that means the whole area, otherwise the area in logic coordinates. + */ + virtual void LogicInvalidate(const tools::Rectangle* pRectangle); + + /** + * Notification about some rectangle of the output device got invalidated. Used for the + * dialogs and floating windows (e.g. context menu, popup). + * + * @param pRectangle If 0, that means the whole area, otherwise the area in pixel coordinates. + */ + virtual void PixelInvalidate(const tools::Rectangle* pRectangle); + void Validate(); + bool HasPaintEvent() const; + void PaintImmediately(); + void Flush() override; + + // toggles new docking support, enabled via toolkit + void EnableDocking( bool bEnable = true ); + // retrieves the single dockingmanager instance + static DockingManager* GetDockingManager(); + + void EnablePaint( bool bEnable ); + bool IsPaintEnabled() const; + void SetUpdateMode( bool bUpdate ); + bool IsUpdateMode() const; + void SetParentUpdateMode( bool bUpdate ); + + void GrabFocus(); + bool HasFocus() const; + bool HasChildPathFocus( bool bSystemWindow = false ) const; + bool IsActive() const; + bool HasActiveChildFrame() const; + GetFocusFlags GetGetFocusFlags() const; + void GrabFocusToDocument(); + VclPtr<vcl::Window> GetFocusedWindow() const; + + /** + * Set this when you need to act as if the window has focus even if it + * doesn't. This is necessary for implementing tab stops inside floating + * windows, but floating windows don't get focus from the system. + */ + void SetFakeFocus( bool bFocus ); + + bool IsCompoundControl() const; + + static VclPtr<vcl::Window> SaveFocus(); + static void EndSaveFocus(const VclPtr<vcl::Window>& xFocusWin); + + void CaptureMouse(); + void ReleaseMouse(); + bool IsMouseCaptured() const; + + void SetPointer( PointerStyle ); + PointerStyle GetPointer() const; + void EnableChildPointerOverwrite( bool bOverwrite ); + void SetPointerPosPixel( const Point& rPos ); + Point GetPointerPosPixel(); + Point GetLastPointerPosPixel(); + /// Similar to SetPointerPosPixel(), but sets the frame data's last mouse position instead. + void SetLastMousePos(const Point& rPos); + void ShowPointer( bool bVisible ); + void EnterWait(); + void LeaveWait(); + bool IsWait() const; + + void SetCursor( vcl::Cursor* pCursor ); + vcl::Cursor* GetCursor() const; + + void SetZoom( const Fraction& rZoom ); + const Fraction& GetZoom() const; + bool IsZoom() const; + long CalcZoom( long n ) const; + + virtual void SetText( const OUString& rStr ); + virtual OUString GetText() const; + // return the actual text displayed + // this may have e.g. accelerators removed or portions + // replaced by ellipses + virtual OUString GetDisplayText() const; + // gets the visible background color. for transparent windows + // this may be the parent's background color; for controls + // this may be a child's background color (e.g. ListBox) + virtual const Wallpaper& GetDisplayBackground() const; + + void SetHelpText( const OUString& rHelpText ); + const OUString& GetHelpText() const; + + void SetQuickHelpText( const OUString& rHelpText ); + const OUString& GetQuickHelpText() const; + + void SetHelpId( const OString& ); + const OString& GetHelpId() const; + + vcl::Window* FindWindow( const Point& rPos ) const; + + sal_uInt16 GetChildCount() const; + vcl::Window* GetChild( sal_uInt16 nChild ) const; + vcl::Window* GetWindow( GetWindowType nType ) const; + bool IsChild( const vcl::Window* pWindow ) const; + bool IsWindowOrChild( const vcl::Window* pWindow, bool bSystemWindow = false ) const; + + /// Add all children to rAllChildren recursively. + SAL_DLLPRIVATE void CollectChildren(::std::vector<vcl::Window *>& rAllChildren ); + + virtual void ShowFocus(const tools::Rectangle& rRect); + void HideFocus(); + + // transparent background for selected or checked items in toolboxes etc. + void DrawSelectionBackground( const tools::Rectangle& rRect, sal_uInt16 highlight, bool bChecked, bool bDrawBorder ); + + void ShowTracking( const tools::Rectangle& rRect, + ShowTrackFlags nFlags = ShowTrackFlags::Small ); + void HideTracking(); + void InvertTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags ); + + void StartTracking( StartTrackingFlags nFlags = StartTrackingFlags::NONE ); + void EndTracking( TrackingEventFlags nFlags = TrackingEventFlags::NONE ); + bool IsTracking() const; + + void StartAutoScroll( StartAutoScrollFlags nFlags ); + void EndAutoScroll(); + + bool HandleScrollCommand( const CommandEvent& rCmd, + ScrollBar* pHScrl, + ScrollBar* pVScrl ); + + void SaveBackground(VirtualDevice& rSaveDevice, + const Point& rPos, const Size& rSize, const Size&) const override; + + virtual const SystemEnvData* GetSystemData() const; + + // API to set/query the component interfaces + virtual css::uno::Reference< css::awt::XWindowPeer > + GetComponentInterface( bool bCreate = true ); + + void SetComponentInterface( css::uno::Reference< css::awt::XWindowPeer > const & xIFace ); + + /// Interface to register for dialog / window tunneling. + void SetLOKNotifier(const vcl::ILibreOfficeKitNotifier* pNotifier, bool bParent = false); + const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() const; + vcl::LOKWindowId GetLOKWindowId() const; + + /// Find the nearest parent with LOK Notifier; can be itself if this Window has LOK notifier set. + VclPtr<vcl::Window> GetParentWithLOKNotifier(); + + /// Indicate that LOK is not going to use this dialog any more. + void ReleaseLOKNotifier(); + + /// Find an existing Window based on the LOKWindowId. + static VclPtr<vcl::Window> FindLOKWindow(vcl::LOKWindowId nWindowId); + + /// check if LOK Window container is empty + static bool IsLOKWindowsEmpty(); + + /// Dumps itself and potentially its children to a property tree, to be written easily to JSON. + virtual boost::property_tree::ptree DumpAsPropertyTree(); + + /// Same as MouseButtonDown(), but coordinates are in logic unit. used for LOK + virtual void LogicMouseButtonDown(const MouseEvent&) {}; + /// Same as MouseButtonUp(), but coordinates are in logic unit. used for LOK + virtual void LogicMouseButtonUp(const MouseEvent&) {}; + /// Same as MouseMove(), but coordinates are in logic unit. used for LOK + virtual void LogicMouseMove(const MouseEvent&) {}; + + /** @name Accessibility + */ + ///@{ +public: + + css::uno::Reference< css::accessibility::XAccessible > + GetAccessible( bool bCreate = true ); + + virtual css::uno::Reference< css::accessibility::XAccessible > + CreateAccessible(); + + void SetAccessible( const css::uno::Reference< css::accessibility::XAccessible >& ); + + vcl::Window* GetAccessibleParentWindow() const; + sal_uInt16 GetAccessibleChildWindowCount(); + vcl::Window* GetAccessibleChildWindow( sal_uInt16 n ); + + void SetAccessibleRole( sal_uInt16 nRole ); + sal_uInt16 GetAccessibleRole() const; + + void SetAccessibleName( const OUString& rName ); + OUString GetAccessibleName() const; + + void SetAccessibleDescription( const OUString& rDescr ); + OUString GetAccessibleDescription() const; + + void SetAccessibleRelationLabeledBy( vcl::Window* pLabeledBy ); + vcl::Window* GetAccessibleRelationLabeledBy() const; + + void SetAccessibleRelationLabelFor( vcl::Window* pLabelFor ); + vcl::Window* GetAccessibleRelationLabelFor() const; + + void SetAccessibleRelationMemberOf( vcl::Window* pMemberOf ); + vcl::Window* GetAccessibleRelationMemberOf() const; + + // to avoid sending accessibility events in cases like closing dialogs + // by default checks complete parent path + bool IsAccessibilityEventsSuppressed( bool bTraverseParentPath = true ); + void SetAccessibilityEventsSuppressed(bool bSuppressed); + + KeyEvent GetActivationKey() const; + +protected: + + // These eventually are supposed to go when everything is converted to .ui + SAL_DLLPRIVATE vcl::Window* getLegacyNonLayoutAccessibleRelationMemberOf() const; + SAL_DLLPRIVATE vcl::Window* getLegacyNonLayoutAccessibleRelationLabeledBy() const; + SAL_DLLPRIVATE vcl::Window* getLegacyNonLayoutAccessibleRelationLabelFor() const; + + // Let Label override the code part of GetAccessibleRelationLabelFor + virtual vcl::Window* getAccessibleRelationLabelFor() const; + virtual sal_uInt16 getDefaultAccessibleRole() const; + virtual OUString getDefaultAccessibleName() const; + + /* + * Advisory Sizing - what is a good size for this widget + * + * Retrieves the preferred size of a widget ignoring + * "width-request" and "height-request" properties. + * + * Implement this in sub-classes to tell layout + * the preferred widget size. + * + * Use get_preferred_size to retrieve this value + * cached and mediated via height and width requests + */ + virtual Size GetOptimalSize() const; + /// clear OptimalSize cache + void InvalidateSizeCache(); +private: + + SAL_DLLPRIVATE bool ImplIsAccessibleCandidate() const; + SAL_DLLPRIVATE bool ImplIsAccessibleNativeFrame() const; + ///@} + + /* + * Retrieves the preferred size of a widget taking + * into account the "width-request" and "height-request" properties. + * + * Overrides the result of GetOptimalSize to honor the + * width-request and height-request properties. + * + * So the same as get_ungrouped_preferred_size except + * it ignores groups. A building block of get_preferred_size + * that access the size cache + * + * @see get_preferred_size + */ + Size get_ungrouped_preferred_size() const; +public: + /// request XCanvas render interface for this window + css::uno::Reference< css::rendering::XCanvas > + GetCanvas() const; + /// request XSpriteCanvas render interface for this window + css::uno::Reference< css::rendering::XSpriteCanvas > + GetSpriteCanvas() const; + + /* records all DrawText operations within the passed rectangle; + * a synchronous paint is sent to achieve this + */ + void RecordLayoutData( vcl::ControlLayoutData* pLayout, const tools::Rectangle& rRect ); + + // set and retrieve for Toolkit + VCLXWindow* GetWindowPeer() const; + void SetWindowPeer( css::uno::Reference< css::awt::XWindowPeer > const & xPeer, VCLXWindow* pVCLXWindow ); + + // remember if it was generated by Toolkit + bool IsCreatedWithToolkit() const; + void SetCreatedWithToolkit( bool b ); + + // Drag and Drop interfaces + css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget(); + css::uno::Reference< css::datatransfer::dnd::XDragSource > GetDragSource(); + css::uno::Reference< css::datatransfer::dnd::XDragGestureRecognizer > GetDragGestureRecognizer(); + + // Clipboard/Selection interfaces + css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard(); + /// Sets a custom clipboard for the window's frame, instead of creating it on-demand using css::datatransfer::clipboard::SystemClipboard. + void SetClipboard(css::uno::Reference<css::datatransfer::clipboard::XClipboard> const & xClipboard); + css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetPrimarySelection(); + + /* + * Widgets call this to inform their owner container that the widget wants + * to renegotiate its size. Should be called when a widget has a new size + * request. e.g. a FixedText Control gets a new label. + * + * akin to gtk_widget_queue_resize + */ + virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout); + + /* + * Sets the "height-request" property + * + * Override for height request of the widget, or -1 if natural request + * should be used. + * + * @see get_preferred_size, set_width_request + */ + void set_height_request(sal_Int32 nHeightRequest); + sal_Int32 get_height_request() const; + + /* + * Sets the "width-request" property + * + * Override for width request of the widget, or -1 if natural request + * should be used. + * + * @see get_preferred_size, set_height_request + */ + void set_width_request(sal_Int32 nWidthRequest); + sal_Int32 get_width_request() const; + + /* + * Retrieves the preferred size of a widget taking + * into account the "width-request" and "height-request" properties. + * + * Overrides the result of GetOptimalSize to honor the + * width-request and height-request properties. + * + * @see GetOptimalSize + * + * akin to gtk_widget_get_preferred_size + */ + Size get_preferred_size() const; + + /* + * How to horizontally align this widget + */ + VclAlign get_halign() const; + void set_halign(VclAlign eAlign); + + /* + * How to vertically align this widget + */ + VclAlign get_valign() const; + void set_valign(VclAlign eAlign); + + /* + * Whether the widget would like to use any available extra horizontal + * space. + */ + bool get_hexpand() const; + void set_hexpand(bool bExpand); + + /* + * Whether the widget would like to use any available extra vertical + * space. + */ + bool get_vexpand() const; + void set_vexpand(bool bExpand); + + /* + * Whether the widget would like to use any available extra space. + */ + bool get_expand() const; + void set_expand(bool bExpand); + + /* + * Whether the widget should receive extra space when the parent grows + */ + bool get_fill() const; + void set_fill(bool bFill); + + void set_border_width(sal_Int32 nBorderWidth); + sal_Int32 get_border_width() const; + + void set_margin_left(sal_Int32 nWidth); + sal_Int32 get_margin_left() const; + + void set_margin_right(sal_Int32 nWidth); + sal_Int32 get_margin_right() const; + + void set_margin_top(sal_Int32 nWidth); + sal_Int32 get_margin_top() const; + + void set_margin_bottom(sal_Int32 nWidth); + sal_Int32 get_margin_bottom() const; + + /* + * How the widget is packed with reference to the start or end of the parent + */ + VclPackType get_pack_type() const; + void set_pack_type(VclPackType ePackType); + + /* + * The extra space to put between the widget and its neighbors + */ + sal_Int32 get_padding() const; + void set_padding(sal_Int32 nPadding); + + /* + * The number of columns that the widget spans + */ + sal_Int32 get_grid_width() const; + void set_grid_width(sal_Int32 nCols); + + /* + * The column number to attach the left side of the widget to + */ + sal_Int32 get_grid_left_attach() const; + void set_grid_left_attach(sal_Int32 nAttach); + + /* + * The number of row that the widget spans + */ + sal_Int32 get_grid_height() const; + void set_grid_height(sal_Int32 nRows); + + /* + * The row number to attach the top side of the widget to + */ + sal_Int32 get_grid_top_attach() const; + void set_grid_top_attach(sal_Int32 nAttach); + + /* + * If true this child appears in a secondary layout group of children + * e.g. help buttons in a buttonbox + */ + bool get_secondary() const; + void set_secondary(bool bSecondary); + + /* + * If true this child is exempted from homogeneous sizing + * e.g. special button in a buttonbox + */ + bool get_non_homogeneous() const; + void set_non_homogeneous(bool bNonHomogeneous); + + /* + * Sets a widget property + * + * @return false if property is unknown + */ + virtual bool set_property(const OString &rKey, const OUString &rValue); + + /* + * Sets a font attribute + * + * @return false if attribute is unknown + */ + bool set_font_attribute(const OString &rKey, const OUString &rValue); + + /* + * Adds this widget to the xGroup VclSizeGroup + * + */ + void add_to_size_group(const std::shared_ptr<VclSizeGroup>& xGroup); + void remove_from_all_size_groups(); + + /* + * add/remove mnemonic label + */ + void add_mnemonic_label(FixedText *pLabel); + void remove_mnemonic_label(FixedText *pLabel); + const std::vector<VclPtr<FixedText> >& list_mnemonic_labels() const; + + /* + * Move this widget to be the nNewPosition'd child of its parent + */ + void reorderWithinParent(sal_uInt16 nNewPosition); + + /** + * Sets an ID. + */ + void set_id(const OUString& rID); + + /** + * Get the ID of the window. + */ + const OUString& get_id() const; + + + // Native Widget Rendering functions + + + // form controls must never use native widgets, this can be toggled here + void EnableNativeWidget( bool bEnable = true ); + bool IsNativeWidgetEnabled() const; + + // a helper method for a Control's Draw method + void PaintToDevice( ::OutputDevice* pDevice, const Point& rPos ); + + /* tdf#119390 set parent to default window. Typically for use in advance of destroying + * a floating windows which has the current focus so focus will revert to the main + * document window and not the first widget in the current parent of the floating + * window. + */ + void SetParentToDefaultWindow(); + + + // Keyboard access functions + + /** Query the states of keyboard indicators - Caps Lock, Num Lock and + Scroll Lock. Use the following mask to retrieve the state of each + indicator: + + KeyIndicatorState::CAPS_LOCK + KeyIndicatorState::NUM_LOCK + KeyIndicatorState::SCROLL_LOCK + */ + KeyIndicatorState GetIndicatorState() const; + + void SimulateKeyPress( sal_uInt16 nKeyCode ) const; + + virtual OUString GetSurroundingText() const; + virtual Selection GetSurroundingTextSelection() const; + + virtual FactoryFunction GetUITestFactory() const; + + virtual bool IsChart() const { return false; } + + void SetHelpHdl(const Link<vcl::Window&, bool>& rLink); + void SetMnemonicActivateHdl(const Link<vcl::Window&, bool>& rLink); + void SetModalHierarchyHdl(const Link<bool, void>& rLink); + void SetDumpAsPropertyTreeHdl(const Link<boost::property_tree::ptree&, void>& rLink); +}; + +} + +#endif // INCLUDED_VCL_WINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/windowstate.hxx b/include/vcl/windowstate.hxx new file mode 100644 index 000000000..393551261 --- /dev/null +++ b/include/vcl/windowstate.hxx @@ -0,0 +1,82 @@ +/* -*- 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_WINDOWSTATE_HXX +#define INCLUDED_VCL_WINDOWSTATE_HXX + +#include <vcl/dllapi.h> +#include <vcl/vclenum.hxx> + +class VCL_PLUGIN_PUBLIC WindowStateData +{ +private: + WindowStateMask mnValidMask; + int mnX; + int mnY; + unsigned int mnWidth; + unsigned int mnHeight; + int mnMaximizedX; + int mnMaximizedY; + unsigned int mnMaximizedWidth; + unsigned int mnMaximizedHeight; + WindowStateState mnState; + +public: + WindowStateData() + : mnValidMask(WindowStateMask::NONE) + , mnX(0) + , mnY(0) + , mnWidth(0) + , mnHeight(0) + , mnMaximizedX(0) + , mnMaximizedY(0) + , mnMaximizedWidth(0) + , mnMaximizedHeight(0) + , mnState(WindowStateState::NONE) + { + } + + void SetMask(WindowStateMask nValidMask) { mnValidMask = nValidMask; } + WindowStateMask GetMask() const { return mnValidMask; } + + void SetX(int nX) { mnX = nX; } + int GetX() const { return mnX; } + void SetY(int nY) { mnY = nY; } + int GetY() const { return mnY; } + void SetWidth(unsigned int nWidth) { mnWidth = nWidth; } + unsigned int GetWidth() const { return mnWidth; } + void SetHeight(unsigned int nHeight) { mnHeight = nHeight; } + unsigned int GetHeight() const { return mnHeight; } + void SetState(WindowStateState nState) { mnState = nState; } + WindowStateState GetState() const { return mnState; } + void SetMaximizedX(int nRX) { mnMaximizedX = nRX; } + int GetMaximizedX() const { return mnMaximizedX; } + void SetMaximizedY(int nRY) { mnMaximizedY = nRY; } + int GetMaximizedY() const { return mnMaximizedY; } + void SetMaximizedWidth(unsigned int nRWidth) { mnMaximizedWidth = nRWidth; } + unsigned int GetMaximizedWidth() const { return mnMaximizedWidth; } + void SetMaximizedHeight(unsigned int nRHeight) { mnMaximizedHeight = nRHeight; } + unsigned int GetMaximizedHeight() const { return mnMaximizedHeight; } + + OString ToStr() const; +}; + +#endif // INCLUDED_VCL_WINDOWSTATE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/winscheduler.hxx b/include/vcl/winscheduler.hxx new file mode 100644 index 000000000..a984b4544 --- /dev/null +++ b/include/vcl/winscheduler.hxx @@ -0,0 +1,44 @@ +/* -*- 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_WINSCHEDULER_HXX +#define INCLUDED_VCL_WINSCHEDULER_HXX + +#ifndef _WIN32 +#error This header is just usable on Windows +#else + +#include <vcl/dllapi.h> + +struct VCL_DLLPUBLIC WinScheduler final +{ + /// Hack for Windows native dialogs, which run the main loop, so we can't + /// use the direct processing shortcut. + static void SetForceRealTimer(); + + // Posting a dummy messages might be needed to ensure that main loop eventually returns from + // GetMessage ("wakes up") in modes without a visible window. This, e.g., might be needed to + // let main thread recheck a condition set from another thread. + static void PostDummyMessage(); +}; + +#endif // _WIN32 +#endif // INCLUDED_VCL_WINSCHEDULER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wizardmachine.hxx b/include/vcl/wizardmachine.hxx new file mode 100644 index 000000000..365f875f8 --- /dev/null +++ b/include/vcl/wizardmachine.hxx @@ -0,0 +1,357 @@ +/* -*- 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_WIZARDMACHINE_HXX +#define INCLUDED_VCL_WIZARDMACHINE_HXX + +#include <memory> +#include <vcl/dllapi.h> +#include <vcl/builderpage.hxx> +#include <vcl/idle.hxx> + +namespace weld { + class Builder; + class Container; +} + +struct WizPageData; +struct ImplWizButtonData; + +// wizard states +#define WZS_INVALID_STATE (::vcl::WizardTypes::WizardState(-1)) + +namespace vcl +{ + //= WizardTypes + namespace WizardTypes + { + typedef sal_Int16 WizardState; + enum CommitPageReason + { + eTravelForward, // traveling forward (maybe with skipping pages) + eTravelBackward, // traveling backward (maybe with skipping pages) + eFinish, // the wizard is about to be finished + eValidate // the data should be validated only, no traveling will happen + }; + }; + + class SAL_NO_VTABLE IWizardPageController + { + public: + + // This methods behave somewhat different than ActivatePage/DeactivatePage + // The latter are handled by the base class itself whenever changing the pages is in the offing, + // i.e., when it's already decided which page is the next. + // We may have situations where the next page depends on the state of the current, which needs + // to be committed for this. + // So initializePage and commitPage are designated to initializing/committing data on the page. + virtual void initializePage() = 0; + virtual bool commitPage( WizardTypes::CommitPageReason _eReason ) = 0; + + /** determines whether or not it is allowed to advance to a next page + + You should make this dependent on the current state of the page only, not on + states on other pages of the whole dialog. + + The default implementation always returns <TRUE/>. + */ + virtual bool canAdvance() const = 0; + + protected: + ~IWizardPageController() {} + }; + + //= OWizardPage + class VCL_DLLPUBLIC OWizardPage : public BuilderPage, public IWizardPageController + { + public: + OWizardPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID); + virtual ~OWizardPage() override; + + // IWizardPageController overridables + virtual void initializePage() override; + virtual bool commitPage( WizardTypes::CommitPageReason _eReason ) override; + virtual bool canAdvance() const override; + + protected: + // BuilderPage overridables + virtual void Activate() override; + + /** updates the travel-related UI elements of the OWizardMachine we live in (if any) + + If the parent of the tab page is an OWizardMachine, then updateTravelUI at this instance + is called. Otherwise, nothing happens. + */ + void updateDialogTravelUI(); + }; + + //= OWizardMachine + struct WizardMachineImplData; + /** implements some kind of finite automata, where the states of the automata exactly correlate + with tab pages. + + That is, the machine can have up to n states, where at each point in time exactly one state is + the current one. A state being current is represented as one of n tab pages being displayed + currently. + + The class handles the UI for traveling between the states (e.g. it administrates the <em>Next</em> and + <em>Previous</em> buttons which you usually find in a wizard. + + Derived classes have to implement the travel logic by overriding <member>determineNextState</member>, + which has to determine the state which follows the current state. Since this may depend + on the actual data presented in the wizard (e.g. checkboxes checked, or something like this), + they can implement non-linear traveling this way. + */ + class VCL_DLLPUBLIC WizardMachine : public weld::AssistantController + { + protected: + BuilderPage* m_pCurTabPage; + private: + WizardTypes::WizardState m_nCurState; + WizPageData* m_pFirstPage; + + protected: + std::unique_ptr<weld::Button> m_xFinish; + std::unique_ptr<weld::Button> m_xCancel; + std::unique_ptr<weld::Button> m_xNextPage; + std::unique_ptr<weld::Button> m_xPrevPage; + std::unique_ptr<weld::Button> m_xHelp; + + private: + // hold members in this structure to allow keeping compatible when members are added + std::unique_ptr<WizardMachineImplData> m_pImpl; + + public: + WizardMachine(weld::Window* _pParent, WizardButtonFlags _nButtonFlags ); + virtual ~WizardMachine() override; + + bool Finish(short nResult = RET_CANCEL); + bool ShowPage(WizardTypes::WizardState nState); + + bool ShowNextPage(); + bool ShowPrevPage(); + + void AddPage( std::unique_ptr<BuilderPage> xPage ); + void RemovePage( const BuilderPage* pPage ); + void SetPage( WizardTypes::WizardState nLevel, std::unique_ptr<BuilderPage> xPage ); + BuilderPage* GetPage( WizardTypes::WizardState eState ) const; + + /// enable (or disable) buttons + void enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable); + /// set the default style for a button + void defaultButton(WizardButtonFlags _nWizardButtonFlags); + /// set the default style for a button + void defaultButton(weld::Button* _pNewDefButton); + + /// set the base of the title to use - the title of the current page is appended + void setTitleBase(const OUString& _rTitleBase); + + /// determines whether there is a next state to which we can advance + virtual bool canAdvance() const; + + /** updates the user interface which deals with traveling in the wizard + + The default implementation simply checks whether both the current page and the wizard + itself allow to advance to the next state (<code>canAdvance</code>), and enables the "Next" + button if and only if this is the case. + */ + virtual void updateTravelUI(); + + protected: + virtual void ActivatePage(); + virtual bool DeactivatePage(); + + // our own overridables + + /// to override to create new pages + virtual std::unique_ptr<BuilderPage> createPage(WizardTypes::WizardState _nState) = 0; + + /// will be called when a new page is about to be displayed + virtual void enterState(WizardTypes::WizardState _nState); + + /** will be called when the current state is about to be left for the given reason + + The base implementation in this class will simply call <member>OWizardPage::commitPage</member> + for the current page, and return whatever this call returns. + + @param _eReason + The reason why the state is to be left. + @return + <TRUE/> if and only if the page is allowed to be left + */ + virtual bool prepareLeaveCurrentState( WizardTypes::CommitPageReason eReason ); + + /** will be called when the given state is left + + This is the very last possibility for derived classes to veto the deactivation + of a page. + + @todo Normally, we would not need the return value here - derived classes now have + the possibility to veto page deactivations in <member>prepareLeaveCurrentState</member>. However, + changing this return type is too incompatible at the moment ... + + @return + <TRUE/> if and only if the page is allowed to be left + */ + virtual bool leaveState(WizardTypes::WizardState nState); + + /** determine the next state to travel from the given one + + The default behaviour is linear traveling, overwrite this to change it + + Return WZS_INVALID_STATE to prevent traveling. + */ + virtual WizardTypes::WizardState determineNextState(WizardTypes::WizardState nCurrentState) const; + + /** called when the finish button is pressed + <p>By default, only the base class' Finish method (which is not virtual) is called</p> + */ + virtual bool onFinish(); + + /// travel to the next state + bool travelNext(); + + /// travel to the previous state + bool travelPrevious(); + + /** enables the automatic enabled/disabled state of the "Next" button + + If this is <TRUE/>, then upon entering a new state, the "Next" button will automatically be + enabled if and only if determineNextState does not return WZS_INVALID_STATE. + */ + void enableAutomaticNextButtonState(); + bool isAutomaticNextButtonStateEnabled() const; + + /** removes a page from the history. Should be called when the page is being disabled + */ + void removePageFromHistory(WizardTypes::WizardState nToRemove); + + /** skip a state + + The method behaves as if from the current state, <arg>_nSteps</arg> <method>travelNext</method>s were + called, but without actually creating or displaying the \EDntermediate pages. Only the + (<arg>_nSteps</arg> + 1)th page is created. + + The skipped states appear in the state history, so <method>travelPrevious</method> will make use of them. + + A very essential precondition for using this method is that your <method>determineNextState</method> + method is able to determine the next state without actually having the page of the current state. + + @see skipUntil + @see skipBackwardUntil + */ + void skip(); + + /** skips one or more states, until a given state is reached + + The method behaves as if from the current state, <method>travelNext</method>s were called + successively, until <arg>_nTargetState</arg> is reached, but without actually creating or + displaying the \EDntermediate pages. + + The skipped states appear in the state history, so <method>travelPrevious</method> will make use of them. + + @return + <TRUE/> if and only if traveling was successful + + @see skip + @see skipBackwardUntil + */ + bool skipUntil(WizardTypes::WizardState nTargetState); + + /** moves back one or more states, until a given state is reached + + This method allows traveling backwards more than one state without actually showing the intermediate + states. + + For instance, if you want to travel two steps backward at a time, you could used + two travelPrevious calls, but this would <em>show</em> both pages, which is not necessary, + since you're interested in the target page only. Using <member>skipBackwardUntil</member> relieves + you of this. + + @return + <TRUE/> if and only if traveling was successful + + @see skipUntil + @see skip + */ + bool skipBackwardUntil(WizardTypes::WizardState nTargetState); + + /** returns the current state of the machine + + Vulgo, this is the identifier of the current tab page :) + */ + WizardTypes::WizardState getCurrentState() const { return m_nCurState; } + + virtual IWizardPageController* getPageController(BuilderPage* pCurrentPage) const; + + /** retrieves a copy of the state history, i.e. all states we already visited + */ + void getStateHistory(std::vector<WizardTypes::WizardState>& out_rHistory); + + public: + class AccessGuard + { + friend class WizardTravelSuspension; + private: + AccessGuard() { } + }; + + void suspendTraveling( AccessGuard ); + void resumeTraveling( AccessGuard ); + bool isTravelingSuspended() const; + + protected: + BuilderPage* GetOrCreatePage(const WizardTypes::WizardState i_nState); + + private: + DECL_DLLPRIVATE_LINK(OnNextPage, weld::Button&, void); + DECL_DLLPRIVATE_LINK(OnPrevPage, weld::Button&, void); + DECL_DLLPRIVATE_LINK(OnFinish, weld::Button&, void); + DECL_DLLPRIVATE_LINK(OnCancel, weld::Button&, void); + + VCL_DLLPRIVATE void implUpdateTitle(); + VCL_DLLPRIVATE void implConstruct( const WizardButtonFlags _nButtonFlags ); + }; + + + /// helper class to temporarily suspend any traveling in the wizard + class WizardTravelSuspension + { + public: + WizardTravelSuspension(WizardMachine& rWizard) + : m_pWizard(&rWizard) + { + m_pWizard->suspendTraveling(WizardMachine::AccessGuard()); + } + + ~WizardTravelSuspension() + { + m_pWizard->resumeTraveling(WizardMachine::AccessGuard()); + } + + private: + WizardMachine* m_pWizard; + }; +} // namespace vcl + +#define WIZARDDIALOG_BUTTON_STDOFFSET_X 6 +#define WIZARDDIALOG_BUTTON_SMALLSTDOFFSET_X 3 + +#endif // INCLUDED_VCL_WIZARDMACHINE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wmf.hxx b/include/vcl/wmf.hxx new file mode 100644 index 000000000..26a1c7344 --- /dev/null +++ b/include/vcl/wmf.hxx @@ -0,0 +1,39 @@ +/* -*- 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_WMF_HXX +#define INCLUDED_VCL_WMF_HXX + +#include <vcl/dllapi.h> + +class FilterConfigItem; +class GDIMetaFile; +class SvStream; + +VCL_DLLPUBLIC bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF ); + +VCL_DLLPUBLIC bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem const * pConfigItem, bool bPlaceable = true ); + +bool ConvertGDIMetaFileToEMF(const GDIMetaFile & rMTF, SvStream & rTargetStream); + +VCL_DLLPUBLIC bool WriteWindowMetafileBits( SvStream& rStream, const GDIMetaFile& rMTF ); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wmfexternal.hxx b/include/vcl/wmfexternal.hxx new file mode 100644 index 000000000..d20fdf84d --- /dev/null +++ b/include/vcl/wmfexternal.hxx @@ -0,0 +1,56 @@ +/* -*- 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_WMFEXTERNAL_HXX +#define INCLUDED_VCL_WMFEXTERNAL_HXX + +#include <vcl/dllapi.h> +#include <com/sun/star/uno/Sequence.hxx> + +namespace com::sun::star::beans { struct PropertyValue; } + +struct VCL_DLLPUBLIC WmfExternal +{ + sal_uInt16 xExt; + sal_uInt16 yExt; + + /** One of the following values: + <ul> + <li>MM_TEXT</li> + <li>MM_LOMETRIC</li> + <li>MM_HIMETRIC</li> + <li>MM_LOENGLISH</li> + <li>MM_HIENGLISH</li> + <li>MM_TWIPS</li> + <li>MM_ISOTROPIC</li> + <li>MM_ANISOTROPIC</li> + </ul> + If this value is 0, then no external mapmode has been defined, + the internal one should then be used. + */ + sal_uInt16 mapMode; + + WmfExternal(); + css::uno::Sequence< css::beans::PropertyValue > getSequence() const; + bool setSequence(const css::uno::Sequence< css::beans::PropertyValue >& rSequence); +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/wrkwin.hxx b/include/vcl/wrkwin.hxx new file mode 100644 index 000000000..dfc6cc1b3 --- /dev/null +++ b/include/vcl/wrkwin.hxx @@ -0,0 +1,104 @@ +/* -*- 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_WRKWIN_HXX +#define INCLUDED_VCL_WRKWIN_HXX + +#include <vcl/dllapi.h> +#include <vcl/syswin.hxx> +#include <o3tl/typed_flags_set.hxx> + +namespace com::sun::star::uno { class Any; } +struct SystemParentData; + + +// Presentation Flags +enum class PresentationFlags +{ + NONE = 0x0000, + HideAllApps = 0x0001, +}; + +namespace o3tl +{ + template<> struct typed_flags<PresentationFlags> : is_typed_flags<PresentationFlags, 0x0001> {}; +} + + +class VCL_DLLPUBLIC WorkWindow : public SystemWindow +{ +private: + PresentationFlags mnPresentationFlags; + bool mbPresentationMode:1, + mbPresentationVisible:1, + mbPresentationFull:1, + mbFullScreenMode:1; + + SAL_DLLPRIVATE void ImplInitWorkWindowData(); + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, const css::uno::Any& aSystemWorkWindowToken ); + +private: + WorkWindow( const WorkWindow& rWin ) = delete; + WorkWindow& operator =( const WorkWindow& rWin ) = delete; + +protected: + explicit WorkWindow( WindowType nType ); + SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, SystemParentData* pSystemParentData = nullptr ); + SAL_DLLPRIVATE void ImplSetFrameState( WindowStateState aFrameState ); + +public: + explicit WorkWindow( vcl::Window* pParent, WinBits nStyle = WB_STDWORK ); + explicit WorkWindow( vcl::Window* pParent, const css::uno::Any& aSystemWorkWindowToken, WinBits nStyle = WB_STDWORK ); + explicit WorkWindow( SystemParentData* pParent ); // Not in the REMOTE-Version + virtual ~WorkWindow() override; + virtual void dispose() override; + + virtual bool Close() override; + + void ShowFullScreenMode( bool bFullScreenMode, + sal_Int32 nDisplayScreen ); + /** + @overload void ShowFullScreenMode(bool bFullScreenMode, sal_Int32 nDisplayScreen) + */ + void ShowFullScreenMode( bool bFullScreenMode ); + bool IsFullScreenMode() const { return mbFullScreenMode; } + + void StartPresentationMode( bool bPresentation, + PresentationFlags nFlags, + sal_Int32 nDisplayScreen ); + /** + @overload void StartPresentationMode( PresentationFlags nFlags, sal_uInt32 nDisplayScreen) + */ + void StartPresentationMode( PresentationFlags nFlags ); + bool IsPresentationMode() const { return mbPresentationMode; } + + bool IsMinimized() const; + + void SetPluginParent( SystemParentData* pParent ); + + void Minimize(); + void Restore(); + + void Maximize( bool bMaximize = true ); + bool IsMaximized() const; +}; + +#endif // INCLUDED_VCL_WRKWIN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/xtextedt.hxx b/include/vcl/xtextedt.hxx new file mode 100644 index 000000000..94ca9d843 --- /dev/null +++ b/include/vcl/xtextedt.hxx @@ -0,0 +1,39 @@ +/* -*- 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_XTEXTEDT_HXX +#define INCLUDED_VCL_XTEXTEDT_HXX + +#include <vcl/dllapi.h> +#include <vcl/texteng.hxx> + +namespace i18nutil { struct SearchOptions; } + +class VCL_DLLPUBLIC ExtTextEngine : public TextEngine +{ +public: + ExtTextEngine(); + virtual ~ExtTextEngine() override; + + TextSelection MatchGroup( const TextPaM& rCursor ) const; + bool Search( TextSelection& rSel, const i18nutil::SearchOptions& rSearchOptions, bool bForward = true ); +}; + +#endif // INCLUDED_VCL_XTEXTEDT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |