1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #ifndef INCLUDED_SVX_RULRITEM_HXX
20 #define INCLUDED_SVX_RULRITEM_HXX
21 
22 #include <tools/gen.hxx>
23 #include <svl/poolitem.hxx>
24 #include <svx/svxdllapi.h>
25 #include <vector>
26 
27 class SVX_DLLPUBLIC SvxLongLRSpaceItem final : public SfxPoolItem
28 {
29     long    mlLeft;         // nLeft or the negative first-line indentation
30     long    mlRight;        // the unproblematic right edge
31 
32     virtual bool             operator==( const SfxPoolItem& ) const override;
33     virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
34     virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
35 
36     virtual bool GetPresentation( SfxItemPresentation ePres,
37                                   MapUnit eCoreMetric,
38                                   MapUnit ePresMetric,
39                                   OUString &rText, const IntlWrapper& ) const override;
40 
41     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = nullptr ) const override;
42 
43     const SvxLongLRSpaceItem& operator=(const SvxLongLRSpaceItem &) = delete;
44 
45 public:
46     static SfxPoolItem* CreateDefault();
47     SvxLongLRSpaceItem(long lLeft, long lRight, sal_uInt16 nId);
48     SvxLongLRSpaceItem();
49 
GetLeft() const50     long GetLeft() const { return mlLeft;}
GetRight() const51     long GetRight() const { return mlRight;}
52     void SetLeft(long lArgLeft);
53     void SetRight(long lArgRight);
54 };
55 
56 class SVX_DLLPUBLIC SvxLongULSpaceItem final : public SfxPoolItem
57 {
58     long    mlLeft;         // nLeft or the negative first-line indentation
59     long    mlRight;        // the unproblematic right edge
60 
61     virtual bool             operator==( const SfxPoolItem& ) const override;
62     virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
63     virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
64 
65     virtual bool GetPresentation( SfxItemPresentation ePres,
66                                   MapUnit eCoreMetric,
67                                   MapUnit ePresMetric,
68                                   OUString &rText, const IntlWrapper& ) const override;
69 
70     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = nullptr ) const override;
71 
72     const SvxLongULSpaceItem& operator=(const SvxLongULSpaceItem &) = delete;
73 
74 public:
75     static SfxPoolItem* CreateDefault();
76     SvxLongULSpaceItem(long lUpper, long lLower, sal_uInt16 nId);
77     SvxLongULSpaceItem();
78 
GetUpper() const79     long GetUpper() const { return mlLeft;}
GetLower() const80     long GetLower() const { return mlRight;}
81     void SetUpper(long lArgLeft);
82     void SetLower(long lArgRight);
83 };
84 
85 class SVX_DLLPUBLIC SvxPagePosSizeItem : public SfxPoolItem
86 {
87     Point aPos;
88     long lWidth;
89     long lHeight;
90 protected:
91     virtual bool             operator==( const SfxPoolItem& ) const override;
92     virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
93     virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
94 
95     virtual bool GetPresentation( SfxItemPresentation ePres,
96                                   MapUnit eCoreMetric,
97                                   MapUnit ePresMetric,
98                                   OUString &rText, const IntlWrapper& ) const override;
99 
100     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = nullptr ) const override;
101 
102 private:
103     const SvxPagePosSizeItem& operator=(const SvxPagePosSizeItem &) = delete;
104 public:
105     static SfxPoolItem* CreateDefault();
106     SvxPagePosSizeItem(const Point &rPos, long lWidth, long lHeight);
107     SvxPagePosSizeItem();
108 
GetPos() const109     const Point &GetPos() const { return aPos; }
GetWidth() const110     long    GetWidth() const { return lWidth; }
GetHeight() const111     long    GetHeight() const { return lHeight; }
112 };
113 
114 struct SVX_DLLPUBLIC SvxColumnDescription
115 {
116     long     nStart;    /* Start of the column */
117     long     nEnd;      /* End of the column */
118     bool     bVisible;  /* Visibility */
119 
120     long nEndMin; //min. possible position of end
121     long nEndMax; //max. possible position of end
122 
123     SvxColumnDescription(long start, long end, bool bVis);
124 
125     SvxColumnDescription(long start, long end,
126                          long endMin, long endMax, bool bVis);
127 
128     bool operator==(const SvxColumnDescription &rCmp) const;
129     bool operator!=(const SvxColumnDescription &rCmp) const;
130     long GetWidth() const;
131 };
132 
133 template<typename charT, typename traits>
operator <<(std::basic_ostream<charT,traits> & stream,SvxColumnDescription const & dsc)134 inline std::basic_ostream<charT, traits> & operator <<(
135     std::basic_ostream<charT, traits> & stream, SvxColumnDescription const& dsc)
136 {
137     return stream << "{ nStart " << dsc.nStart << " nEnd " << dsc.nEnd
138         << " bVisible " << dsc.bVisible  << " nEndMin " << dsc.nEndMin
139         << " nEndMax " << dsc.nEndMax << " }";
140 }
141 
142 
143 class SVX_DLLPUBLIC SvxColumnItem final : public SfxPoolItem
144 {
145     std::vector<SvxColumnDescription>  aColumns; // Column array
146 
147     long nLeft;             // Left edge for the table
148     long nRight;            // Right edge for the table; for columns always
149                             // equal to the surrounding frame
150     sal_uInt16 nActColumn;  // the current column
151     bool       bTable;      // table?
152     bool       bOrtho;      // evenly spread columns
153 
154     virtual bool operator==( const SfxPoolItem& ) const override;
155 
156     virtual bool GetPresentation( SfxItemPresentation ePres,
157                                   MapUnit eCoreMetric,
158                                   MapUnit ePresMetric,
159                                   OUString &rText,
160                                   const IntlWrapper& ) const override;
161 
162     virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
163     virtual bool         QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
164     virtual bool         PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
165 
166 public:
167     static SfxPoolItem* CreateDefault();
168     // right edge of the surrounding frame
169     // nLeft, nRight each the distance to the surrounding frame
170     SvxColumnItem(sal_uInt16 nAct = 0);
171     SvxColumnItem(sal_uInt16 nActCol, sal_uInt16 nLeft, sal_uInt16 nRight); // Table with borders
172 
173     SvxColumnDescription&       operator[](sal_uInt16 index);
174     const SvxColumnDescription& operator[](sal_uInt16 index) const;
175     SvxColumnDescription&       At(sal_uInt16 index);
176     SvxColumnDescription&       GetActiveColumnDescription();
177 
178     sal_uInt16  Count() const;
179     void        Append(const SvxColumnDescription& rDesc);
180     void        SetLeft(long aLeft);
181     void        SetRight(long aRight);
GetActColumn() const182     sal_uInt16  GetActColumn() const { return nActColumn;}
183     bool        IsFirstAct() const;
184     bool        IsLastAct() const;
GetLeft() const185     long        GetLeft() const { return nLeft;}
GetRight() const186     long        GetRight() const { return nRight;}
IsTable() const187     bool        IsTable() const { return bTable;}
188     bool        CalcOrtho() const;
189     void        SetOrtho(bool bVal);
190     bool        IsConsistent() const;
191 };
192 
193 class SVX_DLLPUBLIC SvxObjectItem final : public SfxPoolItem
194 {
195     long nStartX;   /* Start in x direction */
196     long nEndX;     /* End in x direction */
197     long nStartY;   /* Start in y direction */
198     long nEndY;     /* End in y direction */
199     bool bLimits;   /* boundary limit control by the application */
200 
201     virtual bool             operator==( const SfxPoolItem& ) const override;
202 
203     virtual bool GetPresentation( SfxItemPresentation ePres,
204                                   MapUnit eCoreMetric,
205                                   MapUnit ePresMetric,
206                                   OUString &rText, const IntlWrapper& ) const override;
207 
208     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = nullptr ) const override;
209     virtual bool             QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
210     virtual bool             PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
211 
212     const SvxObjectItem &operator=(const SvxObjectItem &) = delete;
213 
214 public:
215     static SfxPoolItem* CreateDefault();
216     SvxObjectItem(long nStartX, long nEndX,
217                   long nStartY, long nEndY);
218 
GetStartX() const219     long GetStartX() const { return nStartX;}
GetEndX() const220     long GetEndX() const { return nEndX;}
GetStartY() const221     long GetStartY() const { return nStartY;}
GetEndY() const222     long GetEndY() const { return nEndY;}
223 
224     void SetStartX(long lValue);
225     void SetEndX(long lValue);
226     void SetStartY(long lValue);
227     void SetEndY(long lValue);
228 };
229 
230 #endif
231 
232 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
233