1190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5190118d0SAndrew Rist * distributed with this work for additional information
6190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8190118d0SAndrew Rist * "License"); you may not use this file except in compliance
9190118d0SAndrew Rist * with the License. You may obtain a copy of the License at
10190118d0SAndrew Rist *
11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12190118d0SAndrew Rist *
13190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14190118d0SAndrew Rist * software distributed under the License is distributed on an
15190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16190118d0SAndrew Rist * KIND, either express or implied. See the License for the
17190118d0SAndrew Rist * specific language governing permissions and limitations
18190118d0SAndrew Rist * under the License.
19190118d0SAndrew Rist *
20190118d0SAndrew Rist *************************************************************/
21190118d0SAndrew Rist
22190118d0SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
29cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31cdf0e10cSrcweir #include <com/sun/star/table/CellVertJustify.hpp>
32cdf0e10cSrcweir #include <com/sun/star/table/ShadowLocation.hpp>
33cdf0e10cSrcweir #include <com/sun/star/table/TableBorder.hpp>
34cdf0e10cSrcweir #include <com/sun/star/table/ShadowFormat.hpp>
35cdf0e10cSrcweir #include <com/sun/star/table/CellRangeAddress.hpp>
36cdf0e10cSrcweir #include <com/sun/star/table/CellContentType.hpp>
37cdf0e10cSrcweir #include <com/sun/star/table/TableOrientation.hpp>
38cdf0e10cSrcweir #include <com/sun/star/table/CellHoriJustify.hpp>
39cdf0e10cSrcweir #include <com/sun/star/util/SortField.hpp>
40cdf0e10cSrcweir #include <com/sun/star/util/SortFieldType.hpp>
41cdf0e10cSrcweir #include <com/sun/star/table/CellOrientation.hpp>
42cdf0e10cSrcweir #include <com/sun/star/table/CellAddress.hpp>
43cdf0e10cSrcweir #include <com/sun/star/style/PageStyleLayout.hpp>
44cdf0e10cSrcweir #include <com/sun/star/style/BreakType.hpp>
45cdf0e10cSrcweir #include <com/sun/star/style/GraphicLocation.hpp>
46cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
47cdf0e10cSrcweir #include <com/sun/star/awt/Selection.hpp>
48cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
49cdf0e10cSrcweir #include <com/sun/star/text/WritingMode2.hpp>
50cdf0e10cSrcweir #include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
51cdf0e10cSrcweir
52cdf0e10cSrcweir #include <unotools/ucbstreamhelper.hxx>
53cdf0e10cSrcweir #include <limits.h>
54cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
55cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
56cdf0e10cSrcweir #include <tools/urlobj.hxx>
57cdf0e10cSrcweir #include <comphelper/types.hxx>
58cdf0e10cSrcweir #include <svl/memberid.hrc>
59cdf0e10cSrcweir #include <svtools/wallitem.hxx>
60cdf0e10cSrcweir #include <svl/cntwall.hxx>
61cdf0e10cSrcweir #include <rtl/ustring.hxx>
62cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
63cdf0e10cSrcweir #include <svtools/filter.hxx>
64cdf0e10cSrcweir
65cdf0e10cSrcweir #define GLOBALOVERFLOW3
66cdf0e10cSrcweir
67cdf0e10cSrcweir #define _SVX_FRMITEMS_CXX
68cdf0e10cSrcweir
69cdf0e10cSrcweir #include <editeng/editids.hrc>
70cdf0e10cSrcweir #include <editeng/editrids.hrc>
71cdf0e10cSrcweir #include <editeng/pbinitem.hxx>
72cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
73cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
74cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
75cdf0e10cSrcweir #include <editeng/prntitem.hxx>
76cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
77cdf0e10cSrcweir #include <editeng/protitem.hxx>
78cdf0e10cSrcweir #include <editeng/shaditem.hxx>
79cdf0e10cSrcweir #include <editeng/boxitem.hxx>
80cdf0e10cSrcweir #include <editeng/brkitem.hxx>
81cdf0e10cSrcweir #include <editeng/keepitem.hxx>
82cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
83cdf0e10cSrcweir #include <editeng/brshitem.hxx>
84cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
85cdf0e10cSrcweir #include <editeng/itemtype.hxx>
86cdf0e10cSrcweir #include <editeng/eerdll.hxx>
87cdf0e10cSrcweir #include <editeng/unoprnms.hxx>
88cdf0e10cSrcweir #include <editeng/memberids.hrc>
89cdf0e10cSrcweir #include <editeng/editerr.hxx>
90cdf0e10cSrcweir
91cdf0e10cSrcweir using namespace ::rtl;
92cdf0e10cSrcweir using namespace ::com::sun::star;
93cdf0e10cSrcweir
94cdf0e10cSrcweir
95cdf0e10cSrcweir // Konvertierung fuer UNO
96cdf0e10cSrcweir #define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
97cdf0e10cSrcweir #define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
98cdf0e10cSrcweir #define TWIP_TO_MM100_UNSIGNED(TWIP) ((((TWIP)*127L+36L)/72L))
99cdf0e10cSrcweir #define MM100_TO_TWIP_UNSIGNED(MM100) ((((MM100)*72L+63L)/127L))
100cdf0e10cSrcweir
101cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
102cdf0e10cSrcweir
103cdf0e10cSrcweir
SetValueProp(XubString & rStr,const sal_uInt16 nValue,const sal_uInt16 nProp)104cdf0e10cSrcweir inline void SetValueProp( XubString& rStr, const sal_uInt16 nValue,
105cdf0e10cSrcweir const sal_uInt16 nProp )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir if( 100 == nProp )
108cdf0e10cSrcweir rStr += String::CreateFromInt32( nValue );
109cdf0e10cSrcweir else
110cdf0e10cSrcweir ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
SetValueProp(XubString & rStr,const short nValue,const sal_uInt16 nProp)113cdf0e10cSrcweir inline void SetValueProp( XubString& rStr, const short nValue,
114cdf0e10cSrcweir const sal_uInt16 nProp )
115cdf0e10cSrcweir {
116cdf0e10cSrcweir if( 100 == nProp )
117cdf0e10cSrcweir rStr += String::CreateFromInt32( nValue );
118cdf0e10cSrcweir else
119cdf0e10cSrcweir ( rStr += String::CreateFromInt32( nProp )) += sal_Unicode('%');
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir // -----------------------------------------------------------------------
123cdf0e10cSrcweir
124cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxPaperBinItem, SfxByteItem, new SvxPaperBinItem(0));
125cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxSizeItem, SfxPoolItem, new SvxSizeItem(0));
126cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxLRSpaceItem, SfxPoolItem, new SvxLRSpaceItem(0));
127cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxULSpaceItem, SfxPoolItem, new SvxULSpaceItem(0));
128cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxPrintItem, SfxBoolItem, new SvxPrintItem(0));
129cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxOpaqueItem, SfxBoolItem, new SvxOpaqueItem(0));
130cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxProtectItem, SfxPoolItem, new SvxProtectItem(0));
131cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxBrushItem, SfxPoolItem, new SvxBrushItem(0));
132cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxShadowItem, SfxPoolItem, new SvxShadowItem(0));
133cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxBoxItem, SfxPoolItem, new SvxBoxItem(0));
134cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxBoxInfoItem, SfxPoolItem, new SvxBoxInfoItem(0));
135cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxFmtBreakItem, SfxEnumItem, new SvxFmtBreakItem(SVX_BREAK_NONE, 0));
136cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxFmtKeepItem, SfxBoolItem, new SvxFmtKeepItem(sal_False, 0));
137cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxLineItem, SfxPoolItem, new SvxLineItem(0));
138cdf0e10cSrcweir TYPEINIT1_FACTORY(SvxFrameDirectionItem, SfxUInt16Item, new SvxFrameDirectionItem(FRMDIR_HORI_LEFT_TOP, 0));
139cdf0e10cSrcweir
140cdf0e10cSrcweir
141cdf0e10cSrcweir // class SvxPaperBinItem ------------------------------------------------
142cdf0e10cSrcweir
Clone(SfxItemPool *) const143cdf0e10cSrcweir SfxPoolItem* SvxPaperBinItem::Clone( SfxItemPool* ) const
144cdf0e10cSrcweir {
145cdf0e10cSrcweir return new SvxPaperBinItem( *this );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir
148cdf0e10cSrcweir // -----------------------------------------------------------------------
149cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const150cdf0e10cSrcweir SvStream& SvxPaperBinItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir rStrm << GetValue();
153cdf0e10cSrcweir return rStrm;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
156cdf0e10cSrcweir // -----------------------------------------------------------------------
157cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const158cdf0e10cSrcweir SfxPoolItem* SvxPaperBinItem::Create( SvStream& rStrm, sal_uInt16 ) const
159cdf0e10cSrcweir {
160cdf0e10cSrcweir sal_Int8 nBin;
161cdf0e10cSrcweir rStrm >> nBin;
162cdf0e10cSrcweir return new SvxPaperBinItem( Which(), nBin );
163cdf0e10cSrcweir }
164cdf0e10cSrcweir
165cdf0e10cSrcweir // -----------------------------------------------------------------------
166cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const167cdf0e10cSrcweir SfxItemPresentation SvxPaperBinItem::GetPresentation
168cdf0e10cSrcweir (
169cdf0e10cSrcweir SfxItemPresentation ePres,
170cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
171cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
172cdf0e10cSrcweir XubString& rText, const IntlWrapper *
173cdf0e10cSrcweir ) const
174cdf0e10cSrcweir {
175cdf0e10cSrcweir switch ( ePres )
176cdf0e10cSrcweir {
177cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
178cdf0e10cSrcweir rText.Erase();
179cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
180cdf0e10cSrcweir
181cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
182cdf0e10cSrcweir rText = String::CreateFromInt32( GetValue() );
183cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
184cdf0e10cSrcweir
185cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
186cdf0e10cSrcweir {
187cdf0e10cSrcweir sal_uInt8 nValue = GetValue();
188cdf0e10cSrcweir
189cdf0e10cSrcweir if ( PAPERBIN_PRINTER_SETTINGS == nValue )
190cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXSTR_PAPERBIN_SETTINGS);
191cdf0e10cSrcweir else
192cdf0e10cSrcweir {
193cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXSTR_PAPERBIN);
194cdf0e10cSrcweir rText += sal_Unicode(' ');
195cdf0e10cSrcweir rText += String::CreateFromInt32( nValue );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE;
198cdf0e10cSrcweir }
199cdf0e10cSrcweir //no break necessary
200cdf0e10cSrcweir default: ;//prevent warning
201cdf0e10cSrcweir }
202cdf0e10cSrcweir
203cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
204cdf0e10cSrcweir }
205cdf0e10cSrcweir
206cdf0e10cSrcweir // class SvxSizeItem -----------------------------------------------------
207cdf0e10cSrcweir
SvxSizeItem(const sal_uInt16 nId,const Size & rSize)208cdf0e10cSrcweir SvxSizeItem::SvxSizeItem( const sal_uInt16 nId, const Size& rSize ) :
209cdf0e10cSrcweir
210cdf0e10cSrcweir SfxPoolItem( nId ),
211cdf0e10cSrcweir
212cdf0e10cSrcweir aSize( rSize )
213cdf0e10cSrcweir {
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const217cdf0e10cSrcweir sal_Bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
218cdf0e10cSrcweir {
219cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
220cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
221cdf0e10cSrcweir
222cdf0e10cSrcweir awt::Size aTmp(aSize.Width(), aSize.Height());
223cdf0e10cSrcweir if( bConvert )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir aTmp.Height = TWIP_TO_MM100(aTmp.Height);
226cdf0e10cSrcweir aTmp.Width = TWIP_TO_MM100(aTmp.Width);
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir switch( nMemberId )
230cdf0e10cSrcweir {
231cdf0e10cSrcweir case MID_SIZE_SIZE: rVal <<= aTmp; break;
232cdf0e10cSrcweir case MID_SIZE_WIDTH: rVal <<= aTmp.Width; break;
233cdf0e10cSrcweir case MID_SIZE_HEIGHT: rVal <<= aTmp.Height; break;
234cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!"); return sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir
237cdf0e10cSrcweir return sal_True;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)240cdf0e10cSrcweir sal_Bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
243cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
244cdf0e10cSrcweir
245cdf0e10cSrcweir switch( nMemberId )
246cdf0e10cSrcweir {
247cdf0e10cSrcweir case MID_SIZE_SIZE:
248cdf0e10cSrcweir {
249cdf0e10cSrcweir awt::Size aTmp;
250cdf0e10cSrcweir if( rVal >>= aTmp )
251cdf0e10cSrcweir {
252cdf0e10cSrcweir if(bConvert)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir aTmp.Height = MM100_TO_TWIP(aTmp.Height);
255cdf0e10cSrcweir aTmp.Width = MM100_TO_TWIP(aTmp.Width);
256cdf0e10cSrcweir }
257cdf0e10cSrcweir aSize = Size( aTmp.Width, aTmp.Height );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir else
260cdf0e10cSrcweir {
261cdf0e10cSrcweir return sal_False;
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir break;
265cdf0e10cSrcweir case MID_SIZE_WIDTH:
266cdf0e10cSrcweir {
267cdf0e10cSrcweir sal_Int32 nVal = 0;
268cdf0e10cSrcweir if(!(rVal >>= nVal ))
269cdf0e10cSrcweir return sal_False;
270cdf0e10cSrcweir
271cdf0e10cSrcweir aSize.Width() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir break;
274cdf0e10cSrcweir case MID_SIZE_HEIGHT:
275cdf0e10cSrcweir {
276cdf0e10cSrcweir sal_Int32 nVal = 0;
277cdf0e10cSrcweir if(!(rVal >>= nVal))
278cdf0e10cSrcweir return sal_True;
279cdf0e10cSrcweir
280cdf0e10cSrcweir aSize.Height() = bConvert ? MM100_TO_TWIP(nVal) : nVal;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir break;
283cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!");
284cdf0e10cSrcweir return sal_False;
285cdf0e10cSrcweir }
286cdf0e10cSrcweir return sal_True;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir
289cdf0e10cSrcweir // -----------------------------------------------------------------------
290cdf0e10cSrcweir
SvxSizeItem(const sal_uInt16 nId)291cdf0e10cSrcweir SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
292cdf0e10cSrcweir
293cdf0e10cSrcweir SfxPoolItem( nId )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir }
296cdf0e10cSrcweir
297cdf0e10cSrcweir // -----------------------------------------------------------------------
298cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const299cdf0e10cSrcweir int SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const
300cdf0e10cSrcweir {
301cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
302cdf0e10cSrcweir
303cdf0e10cSrcweir return ( aSize == ( (SvxSizeItem&)rAttr ).GetSize() );
304cdf0e10cSrcweir }
305cdf0e10cSrcweir
306cdf0e10cSrcweir // -----------------------------------------------------------------------
307cdf0e10cSrcweir
Clone(SfxItemPool *) const308cdf0e10cSrcweir SfxPoolItem* SvxSizeItem::Clone( SfxItemPool* ) const
309cdf0e10cSrcweir {
310cdf0e10cSrcweir return new SvxSizeItem( *this );
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir //------------------------------------------------------------------------
314cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const315cdf0e10cSrcweir SfxItemPresentation SvxSizeItem::GetPresentation
316cdf0e10cSrcweir (
317cdf0e10cSrcweir SfxItemPresentation ePres,
318cdf0e10cSrcweir SfxMapUnit eCoreUnit,
319cdf0e10cSrcweir SfxMapUnit ePresUnit,
320cdf0e10cSrcweir XubString& rText, const IntlWrapper *pIntl
321cdf0e10cSrcweir ) const
322cdf0e10cSrcweir {
323cdf0e10cSrcweir #ifndef SVX_LIGHT
324cdf0e10cSrcweir switch ( ePres )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
327cdf0e10cSrcweir rText.Erase();
328cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
329cdf0e10cSrcweir
330cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
331cdf0e10cSrcweir rText = GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
332cdf0e10cSrcweir rText += cpDelim;
333cdf0e10cSrcweir rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
334cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
335cdf0e10cSrcweir
336cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
337cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_SIZE_WIDTH);
338cdf0e10cSrcweir rText += GetMetricText( aSize.Width(), eCoreUnit, ePresUnit, pIntl );
339*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
340cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
341cdf0e10cSrcweir rText += cpDelim;
342cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_SIZE_HEIGHT);
343cdf0e10cSrcweir rText += GetMetricText( aSize.Height(), eCoreUnit, ePresUnit, pIntl );
344*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
345cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
346cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE;
347cdf0e10cSrcweir //no break necessary
348cdf0e10cSrcweir default: ;//prevent warning
349cdf0e10cSrcweir
350cdf0e10cSrcweir }
351cdf0e10cSrcweir #endif // !SVX_LIGHT
352cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir
355cdf0e10cSrcweir // -----------------------------------------------------------------------
356cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const357cdf0e10cSrcweir SvStream& SvxSizeItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
358cdf0e10cSrcweir {
359cdf0e10cSrcweir rStrm << aSize.Width();
360cdf0e10cSrcweir rStrm << aSize.Height();
361cdf0e10cSrcweir return rStrm;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
364cdf0e10cSrcweir // -----------------------------------------------------------------------
365cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)366cdf0e10cSrcweir int SvxSizeItem::ScaleMetrics( long nMult, long nDiv )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir aSize.Width() = Scale( aSize.Width(), nMult, nDiv );
369cdf0e10cSrcweir aSize.Height() = Scale( aSize.Height(), nMult, nDiv );
370cdf0e10cSrcweir return 1;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir
373cdf0e10cSrcweir // -----------------------------------------------------------------------
374cdf0e10cSrcweir
HasMetrics() const375cdf0e10cSrcweir int SvxSizeItem::HasMetrics() const
376cdf0e10cSrcweir {
377cdf0e10cSrcweir return 1;
378cdf0e10cSrcweir }
379cdf0e10cSrcweir
380cdf0e10cSrcweir // -----------------------------------------------------------------------
381cdf0e10cSrcweir
382cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const383cdf0e10cSrcweir SfxPoolItem* SvxSizeItem::Create( SvStream& rStrm, sal_uInt16 ) const
384cdf0e10cSrcweir {
385cdf0e10cSrcweir long nWidth, nHeight;
386cdf0e10cSrcweir rStrm >> nWidth >> nHeight;
387cdf0e10cSrcweir
388cdf0e10cSrcweir SvxSizeItem* pAttr = new SvxSizeItem( Which() );
389cdf0e10cSrcweir pAttr->SetSize(Size(nWidth, nHeight));
390cdf0e10cSrcweir
391cdf0e10cSrcweir return pAttr;
392cdf0e10cSrcweir }
393cdf0e10cSrcweir
394cdf0e10cSrcweir // class SvxLRSpaceItem --------------------------------------------------
395cdf0e10cSrcweir
SvxLRSpaceItem(const sal_uInt16 nId)396cdf0e10cSrcweir SvxLRSpaceItem::SvxLRSpaceItem( const sal_uInt16 nId ) :
397cdf0e10cSrcweir
398cdf0e10cSrcweir SfxPoolItem( nId ),
399cdf0e10cSrcweir
400cdf0e10cSrcweir nFirstLineOfst ( 0 ),
401cdf0e10cSrcweir nTxtLeft ( 0 ),
402cdf0e10cSrcweir nLeftMargin ( 0 ),
403cdf0e10cSrcweir nRightMargin ( 0 ),
404cdf0e10cSrcweir nPropFirstLineOfst( 100 ),
405cdf0e10cSrcweir nPropLeftMargin( 100 ),
406cdf0e10cSrcweir nPropRightMargin( 100 ),
407cdf0e10cSrcweir bAutoFirst ( 0 )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir }
410cdf0e10cSrcweir
411cdf0e10cSrcweir // -----------------------------------------------------------------------
412cdf0e10cSrcweir
SvxLRSpaceItem(const long nLeft,const long nRight,const long nTLeft,const short nOfset,const sal_uInt16 nId)413cdf0e10cSrcweir SvxLRSpaceItem::SvxLRSpaceItem( const long nLeft, const long nRight,
414cdf0e10cSrcweir const long nTLeft, const short nOfset,
415cdf0e10cSrcweir const sal_uInt16 nId ) :
416cdf0e10cSrcweir
417cdf0e10cSrcweir SfxPoolItem( nId ),
418cdf0e10cSrcweir
419cdf0e10cSrcweir nFirstLineOfst ( nOfset ),
420cdf0e10cSrcweir nTxtLeft ( nTLeft ),
421cdf0e10cSrcweir nLeftMargin ( nLeft ),
422cdf0e10cSrcweir nRightMargin ( nRight ),
423cdf0e10cSrcweir nPropFirstLineOfst( 100 ),
424cdf0e10cSrcweir nPropLeftMargin( 100 ),
425cdf0e10cSrcweir nPropRightMargin( 100 ),
426cdf0e10cSrcweir bAutoFirst ( 0 )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const431cdf0e10cSrcweir sal_Bool SvxLRSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
432cdf0e10cSrcweir {
433cdf0e10cSrcweir sal_Bool bRet = sal_True;
434cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
435cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
436cdf0e10cSrcweir switch( nMemberId )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir // jetzt alles signed
439cdf0e10cSrcweir case MID_L_MARGIN:
440cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin);
441cdf0e10cSrcweir break;
442cdf0e10cSrcweir
443cdf0e10cSrcweir case MID_TXT_LMARGIN :
444cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nTxtLeft) : nTxtLeft);
445cdf0e10cSrcweir break;
446cdf0e10cSrcweir case MID_R_MARGIN:
447cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin);
448cdf0e10cSrcweir break;
449cdf0e10cSrcweir case MID_L_REL_MARGIN:
450cdf0e10cSrcweir rVal <<= (sal_Int16)nPropLeftMargin;
451cdf0e10cSrcweir break;
452cdf0e10cSrcweir case MID_R_REL_MARGIN:
453cdf0e10cSrcweir rVal <<= (sal_Int16)nPropRightMargin;
454cdf0e10cSrcweir break;
455cdf0e10cSrcweir
456cdf0e10cSrcweir case MID_FIRST_LINE_INDENT:
457cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100(nFirstLineOfst) : nFirstLineOfst);
458cdf0e10cSrcweir break;
459cdf0e10cSrcweir
460cdf0e10cSrcweir case MID_FIRST_LINE_REL_INDENT:
461cdf0e10cSrcweir rVal <<= (sal_Int16)(nPropFirstLineOfst);
462cdf0e10cSrcweir break;
463cdf0e10cSrcweir
464cdf0e10cSrcweir case MID_FIRST_AUTO:
465cdf0e10cSrcweir rVal = Bool2Any(IsAutoFirst());
466cdf0e10cSrcweir break;
467cdf0e10cSrcweir
468cdf0e10cSrcweir default:
469cdf0e10cSrcweir bRet = sal_False;
470cdf0e10cSrcweir DBG_ERROR("unknown MemberId");
471cdf0e10cSrcweir }
472cdf0e10cSrcweir return bRet;
473cdf0e10cSrcweir }
474cdf0e10cSrcweir
475cdf0e10cSrcweir // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)476cdf0e10cSrcweir sal_Bool SvxLRSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
479cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
480cdf0e10cSrcweir sal_Int32 nVal = 0;
481cdf0e10cSrcweir if( nMemberId != MID_FIRST_AUTO &&
482cdf0e10cSrcweir nMemberId != MID_L_REL_MARGIN && nMemberId != MID_R_REL_MARGIN)
483cdf0e10cSrcweir if(!(rVal >>= nVal))
484cdf0e10cSrcweir return sal_False;
485cdf0e10cSrcweir
486cdf0e10cSrcweir switch( nMemberId )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir case MID_L_MARGIN:
489cdf0e10cSrcweir SetLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
490cdf0e10cSrcweir break;
491cdf0e10cSrcweir
492cdf0e10cSrcweir case MID_TXT_LMARGIN :
493cdf0e10cSrcweir SetTxtLeft((sal_Int32)bConvert ? MM100_TO_TWIP(nVal) : nVal);
494cdf0e10cSrcweir break;
495cdf0e10cSrcweir
496cdf0e10cSrcweir case MID_R_MARGIN:
497cdf0e10cSrcweir SetRight((sal_Int32) bConvert ? MM100_TO_TWIP(nVal) : nVal);
498cdf0e10cSrcweir break;
499cdf0e10cSrcweir case MID_L_REL_MARGIN:
500cdf0e10cSrcweir case MID_R_REL_MARGIN:
501cdf0e10cSrcweir {
502cdf0e10cSrcweir sal_Int32 nRel = 0;
503cdf0e10cSrcweir if((rVal >>= nRel) && nRel >= 0 && nRel < USHRT_MAX)
504cdf0e10cSrcweir {
505cdf0e10cSrcweir if(MID_L_REL_MARGIN== nMemberId)
506cdf0e10cSrcweir nPropLeftMargin = (sal_uInt16)nRel;
507cdf0e10cSrcweir else
508cdf0e10cSrcweir nPropRightMargin = (sal_uInt16)nRel;
509cdf0e10cSrcweir }
510cdf0e10cSrcweir else
511cdf0e10cSrcweir return sal_False;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir break;
514cdf0e10cSrcweir case MID_FIRST_LINE_INDENT :
515cdf0e10cSrcweir SetTxtFirstLineOfst((short)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
516cdf0e10cSrcweir break;
517cdf0e10cSrcweir
518cdf0e10cSrcweir case MID_FIRST_LINE_REL_INDENT:
519cdf0e10cSrcweir SetPropTxtFirstLineOfst ( (sal_uInt16)nVal );
520cdf0e10cSrcweir break;
521cdf0e10cSrcweir
522cdf0e10cSrcweir case MID_FIRST_AUTO:
523cdf0e10cSrcweir SetAutoFirst( Any2Bool(rVal) );
524cdf0e10cSrcweir break;
525cdf0e10cSrcweir
526cdf0e10cSrcweir default:
527cdf0e10cSrcweir DBG_ERROR("unknown MemberId");
528cdf0e10cSrcweir return sal_False;
529cdf0e10cSrcweir }
530cdf0e10cSrcweir return sal_True;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir
533cdf0e10cSrcweir // -----------------------------------------------------------------------
534cdf0e10cSrcweir
535cdf0e10cSrcweir // nLeftMargin und nTxtLeft anpassen.
536cdf0e10cSrcweir
AdjustLeft()537cdf0e10cSrcweir void SvxLRSpaceItem::AdjustLeft()
538cdf0e10cSrcweir {
539cdf0e10cSrcweir if ( 0 > nFirstLineOfst )
540cdf0e10cSrcweir nLeftMargin = nTxtLeft + nFirstLineOfst;
541cdf0e10cSrcweir else
542cdf0e10cSrcweir nLeftMargin = nTxtLeft;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
545cdf0e10cSrcweir // -----------------------------------------------------------------------
546cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const547cdf0e10cSrcweir int SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
548cdf0e10cSrcweir {
549cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
550cdf0e10cSrcweir
551cdf0e10cSrcweir return (
552cdf0e10cSrcweir nLeftMargin == ((SvxLRSpaceItem&)rAttr).GetLeft() &&
553cdf0e10cSrcweir nRightMargin == ((SvxLRSpaceItem&)rAttr).GetRight() &&
554cdf0e10cSrcweir nFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetTxtFirstLineOfst() &&
555cdf0e10cSrcweir nPropLeftMargin == ((SvxLRSpaceItem&)rAttr).GetPropLeft() &&
556cdf0e10cSrcweir nPropRightMargin == ((SvxLRSpaceItem&)rAttr).GetPropRight() &&
557cdf0e10cSrcweir nPropFirstLineOfst == ((SvxLRSpaceItem&)rAttr).GetPropTxtFirstLineOfst() &&
558cdf0e10cSrcweir bAutoFirst == ((SvxLRSpaceItem&)rAttr).IsAutoFirst() );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir // -----------------------------------------------------------------------
562cdf0e10cSrcweir
Clone(SfxItemPool *) const563cdf0e10cSrcweir SfxPoolItem* SvxLRSpaceItem::Clone( SfxItemPool* ) const
564cdf0e10cSrcweir {
565cdf0e10cSrcweir return new SvxLRSpaceItem( *this );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir
568cdf0e10cSrcweir //------------------------------------------------------------------------
569cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const570cdf0e10cSrcweir SfxItemPresentation SvxLRSpaceItem::GetPresentation
571cdf0e10cSrcweir (
572cdf0e10cSrcweir SfxItemPresentation ePres,
573cdf0e10cSrcweir SfxMapUnit eCoreUnit,
574cdf0e10cSrcweir SfxMapUnit ePresUnit,
575cdf0e10cSrcweir XubString& rText, const IntlWrapper* pIntl
576cdf0e10cSrcweir ) const
577cdf0e10cSrcweir {
578cdf0e10cSrcweir #ifndef SVX_LIGHT
579cdf0e10cSrcweir switch ( ePres )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
582cdf0e10cSrcweir rText.Erase();
583cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
584cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
585cdf0e10cSrcweir {
586cdf0e10cSrcweir if ( 100 != nPropLeftMargin )
587cdf0e10cSrcweir ( rText = String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
588cdf0e10cSrcweir else
589cdf0e10cSrcweir rText = GetMetricText( (long)nLeftMargin,
590cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
591cdf0e10cSrcweir rText += cpDelim;
592cdf0e10cSrcweir if ( 100 != nPropFirstLineOfst )
593cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropFirstLineOfst )) += sal_Unicode('%');
594cdf0e10cSrcweir else
595cdf0e10cSrcweir rText += GetMetricText( (long)nFirstLineOfst,
596cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
597cdf0e10cSrcweir rText += cpDelim;
598cdf0e10cSrcweir if ( 100 != nRightMargin )
599cdf0e10cSrcweir ( rText += String::CreateFromInt32( nRightMargin )) += sal_Unicode('%');
600cdf0e10cSrcweir else
601cdf0e10cSrcweir rText += GetMetricText( (long)nRightMargin,
602cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
603cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
606cdf0e10cSrcweir {
607cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_LRSPACE_LEFT);
608cdf0e10cSrcweir if ( 100 != nPropLeftMargin )
609cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropLeftMargin )) += sal_Unicode('%');
610cdf0e10cSrcweir else
611cdf0e10cSrcweir {
612cdf0e10cSrcweir rText += GetMetricText( (long)nLeftMargin,
613cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
614*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
615cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
616cdf0e10cSrcweir }
617cdf0e10cSrcweir rText += cpDelim;
618cdf0e10cSrcweir if ( 100 != nPropFirstLineOfst || nFirstLineOfst )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_FLINE);
621cdf0e10cSrcweir if ( 100 != nPropFirstLineOfst )
622cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropFirstLineOfst ))
623cdf0e10cSrcweir += sal_Unicode('%');
624cdf0e10cSrcweir else
625cdf0e10cSrcweir {
626cdf0e10cSrcweir rText += GetMetricText( (long)nFirstLineOfst,
627cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
628*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
629cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
630cdf0e10cSrcweir }
631cdf0e10cSrcweir rText += cpDelim;
632cdf0e10cSrcweir }
633cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_LRSPACE_RIGHT);
634cdf0e10cSrcweir if ( 100 != nPropRightMargin )
635cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropRightMargin )) += sal_Unicode('%');
636cdf0e10cSrcweir else
637cdf0e10cSrcweir {
638cdf0e10cSrcweir rText += GetMetricText( (long)nRightMargin,
639cdf0e10cSrcweir eCoreUnit, ePresUnit, pIntl );
640*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
641cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
642cdf0e10cSrcweir }
643cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE;
644cdf0e10cSrcweir }
645cdf0e10cSrcweir default: ;//prevent warning
646cdf0e10cSrcweir }
647cdf0e10cSrcweir #endif // !SVX_LIGHT
648cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
649cdf0e10cSrcweir }
650cdf0e10cSrcweir
651cdf0e10cSrcweir // -----------------------------------------------------------------------
652cdf0e10cSrcweir
653cdf0e10cSrcweir // MT: BulletFI: Vor 501 wurde im Outliner das Bullet nicht auf der Position des
654cdf0e10cSrcweir // FI positioniert, deshalb muss in aelteren Dokumenten der FI auf 0 stehen.
655cdf0e10cSrcweir
656cdf0e10cSrcweir #define BULLETLR_MARKER 0x599401FE
657cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const658cdf0e10cSrcweir SvStream& SvxLRSpaceItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
659cdf0e10cSrcweir {
660cdf0e10cSrcweir short nSaveFI = nFirstLineOfst;
661cdf0e10cSrcweir ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( 0 ); // nLeftMargin wird mitmanipuliert, siehe Create()
662cdf0e10cSrcweir
663cdf0e10cSrcweir sal_uInt16 nMargin = 0;
664cdf0e10cSrcweir if( nLeftMargin > 0 )
665cdf0e10cSrcweir nMargin = sal_uInt16( nLeftMargin );
666cdf0e10cSrcweir rStrm << nMargin;
667cdf0e10cSrcweir rStrm << nPropLeftMargin;
668cdf0e10cSrcweir if( nRightMargin > 0 )
669cdf0e10cSrcweir nMargin = sal_uInt16( nRightMargin );
670cdf0e10cSrcweir else
671cdf0e10cSrcweir nMargin = 0;
672cdf0e10cSrcweir rStrm << nMargin;
673cdf0e10cSrcweir rStrm << nPropRightMargin;
674cdf0e10cSrcweir rStrm << nFirstLineOfst;
675cdf0e10cSrcweir rStrm << nPropFirstLineOfst;
676cdf0e10cSrcweir if( nTxtLeft > 0 )
677cdf0e10cSrcweir nMargin = sal_uInt16( nTxtLeft );
678cdf0e10cSrcweir else
679cdf0e10cSrcweir nMargin = 0;
680cdf0e10cSrcweir rStrm << nMargin;
681cdf0e10cSrcweir if( nItemVersion >= LRSPACE_AUTOFIRST_VERSION )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir sal_Int8 nAutoFirst = bAutoFirst ? 1 : 0;
684cdf0e10cSrcweir if( nItemVersion >= LRSPACE_NEGATIVE_VERSION &&
685cdf0e10cSrcweir ( nLeftMargin < 0 || nRightMargin < 0 || nTxtLeft < 0 ) )
686cdf0e10cSrcweir nAutoFirst |= 0x80;
687cdf0e10cSrcweir rStrm << nAutoFirst;
688cdf0e10cSrcweir
689cdf0e10cSrcweir // Ab 6.0 keine Magicnumber schreiben...
690cdf0e10cSrcweir DBG_ASSERT( rStrm.GetVersion() <= SOFFICE_FILEFORMAT_50, "MT: Fileformat SvxLRSpaceItem aendern!" );
691cdf0e10cSrcweir rStrm << (sal_uInt32) BULLETLR_MARKER;
692cdf0e10cSrcweir rStrm << nSaveFI;
693cdf0e10cSrcweir
694cdf0e10cSrcweir if( 0x80 & nAutoFirst )
695cdf0e10cSrcweir {
696cdf0e10cSrcweir rStrm << nLeftMargin;
697cdf0e10cSrcweir rStrm << nRightMargin;
698cdf0e10cSrcweir }
699cdf0e10cSrcweir }
700cdf0e10cSrcweir
701cdf0e10cSrcweir ((SvxLRSpaceItem*)this)->SetTxtFirstLineOfst( nSaveFI );
702cdf0e10cSrcweir
703cdf0e10cSrcweir return rStrm;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir
706cdf0e10cSrcweir // -----------------------------------------------------------------------
707cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16 nVersion) const708cdf0e10cSrcweir SfxPoolItem* SvxLRSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
709cdf0e10cSrcweir {
710cdf0e10cSrcweir sal_uInt16 left, prpleft, right, prpright, prpfirstline, txtleft;
711cdf0e10cSrcweir short firstline;
712cdf0e10cSrcweir sal_Int8 autofirst = 0;
713cdf0e10cSrcweir
714cdf0e10cSrcweir if ( nVersion >= LRSPACE_AUTOFIRST_VERSION )
715cdf0e10cSrcweir {
716cdf0e10cSrcweir rStrm >> left >> prpleft >> right >> prpright >> firstline >>
717cdf0e10cSrcweir prpfirstline >> txtleft >> autofirst;
718cdf0e10cSrcweir
719cdf0e10cSrcweir sal_uInt32 nPos = rStrm.Tell();
720cdf0e10cSrcweir sal_uInt32 nMarker;
721cdf0e10cSrcweir rStrm >> nMarker;
722cdf0e10cSrcweir if ( nMarker == BULLETLR_MARKER )
723cdf0e10cSrcweir {
724cdf0e10cSrcweir rStrm >> firstline;
725cdf0e10cSrcweir if ( firstline < 0 )
726cdf0e10cSrcweir left = left + static_cast<sal_uInt16>(firstline); // s.u.: txtleft = ...
727cdf0e10cSrcweir }
728cdf0e10cSrcweir else
729cdf0e10cSrcweir rStrm.Seek( nPos );
730cdf0e10cSrcweir }
731cdf0e10cSrcweir else if ( nVersion == LRSPACE_TXTLEFT_VERSION )
732cdf0e10cSrcweir {
733cdf0e10cSrcweir rStrm >> left >> prpleft >> right >> prpright >> firstline >>
734cdf0e10cSrcweir prpfirstline >> txtleft;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir else if ( nVersion == LRSPACE_16_VERSION )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir rStrm >> left >> prpleft >> right >> prpright >> firstline >>
739cdf0e10cSrcweir prpfirstline;
740cdf0e10cSrcweir }
741cdf0e10cSrcweir else
742cdf0e10cSrcweir {
743cdf0e10cSrcweir sal_Int8 nL, nR, nFL;
744cdf0e10cSrcweir rStrm >> left >> nL >> right >> nR >> firstline >> nFL;
745cdf0e10cSrcweir prpleft = (sal_uInt16)nL;
746cdf0e10cSrcweir prpright = (sal_uInt16)nR;
747cdf0e10cSrcweir prpfirstline = (sal_uInt16)nFL;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir
750cdf0e10cSrcweir txtleft = firstline >= 0 ? left : left - firstline;
751cdf0e10cSrcweir SvxLRSpaceItem* pAttr = new SvxLRSpaceItem( Which() );
752cdf0e10cSrcweir
753cdf0e10cSrcweir pAttr->nLeftMargin = left;
754cdf0e10cSrcweir pAttr->nPropLeftMargin = prpleft;
755cdf0e10cSrcweir pAttr->nRightMargin = right;
756cdf0e10cSrcweir pAttr->nPropRightMargin = prpright;
757cdf0e10cSrcweir pAttr->nFirstLineOfst = firstline;
758cdf0e10cSrcweir pAttr->nPropFirstLineOfst = prpfirstline;
759cdf0e10cSrcweir pAttr->nTxtLeft = txtleft;
760cdf0e10cSrcweir pAttr->bAutoFirst = autofirst & 0x01;
761cdf0e10cSrcweir if( nVersion >= LRSPACE_NEGATIVE_VERSION && ( autofirst & 0x80 ) )
762cdf0e10cSrcweir {
763cdf0e10cSrcweir sal_Int32 nMargin;
764cdf0e10cSrcweir rStrm >> nMargin;
765cdf0e10cSrcweir pAttr->nLeftMargin = nMargin;
766cdf0e10cSrcweir pAttr->nTxtLeft = firstline >= 0 ? nMargin : nMargin - firstline;
767cdf0e10cSrcweir rStrm >> nMargin;
768cdf0e10cSrcweir pAttr->nRightMargin = nMargin;
769cdf0e10cSrcweir }
770cdf0e10cSrcweir return pAttr;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
773cdf0e10cSrcweir // -----------------------------------------------------------------------
774cdf0e10cSrcweir
GetVersion(sal_uInt16 nFileVersion) const775cdf0e10cSrcweir sal_uInt16 SvxLRSpaceItem::GetVersion( sal_uInt16 nFileVersion ) const
776cdf0e10cSrcweir {
777cdf0e10cSrcweir return (nFileVersion == SOFFICE_FILEFORMAT_31)
778cdf0e10cSrcweir ? LRSPACE_TXTLEFT_VERSION
779cdf0e10cSrcweir : LRSPACE_NEGATIVE_VERSION;
780cdf0e10cSrcweir }
781cdf0e10cSrcweir
782cdf0e10cSrcweir // -----------------------------------------------------------------------
783cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)784cdf0e10cSrcweir int SvxLRSpaceItem::ScaleMetrics( long nMult, long nDiv )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir nFirstLineOfst = (short)Scale( nFirstLineOfst, nMult, nDiv );
787cdf0e10cSrcweir nTxtLeft = Scale( nTxtLeft, nMult, nDiv );
788cdf0e10cSrcweir nLeftMargin = Scale( nLeftMargin, nMult, nDiv );
789cdf0e10cSrcweir nRightMargin = Scale( nRightMargin, nMult, nDiv );
790cdf0e10cSrcweir return 1;
791cdf0e10cSrcweir }
792cdf0e10cSrcweir
793cdf0e10cSrcweir // -----------------------------------------------------------------------
794cdf0e10cSrcweir
HasMetrics() const795cdf0e10cSrcweir int SvxLRSpaceItem::HasMetrics() const
796cdf0e10cSrcweir {
797cdf0e10cSrcweir return 1;
798cdf0e10cSrcweir }
799cdf0e10cSrcweir
800cdf0e10cSrcweir // class SvxULSpaceItem --------------------------------------------------
801cdf0e10cSrcweir
SvxULSpaceItem(const sal_uInt16 nId)802cdf0e10cSrcweir SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nId ) :
803cdf0e10cSrcweir
804cdf0e10cSrcweir SfxPoolItem( nId ),
805cdf0e10cSrcweir
806cdf0e10cSrcweir nUpper( 0 ),
807cdf0e10cSrcweir nLower( 0 ),
808cdf0e10cSrcweir nPropUpper( 100 ),
809cdf0e10cSrcweir nPropLower( 100 )
810cdf0e10cSrcweir {
811cdf0e10cSrcweir }
812cdf0e10cSrcweir
813cdf0e10cSrcweir // -----------------------------------------------------------------------
814cdf0e10cSrcweir
SvxULSpaceItem(const sal_uInt16 nUp,const sal_uInt16 nLow,const sal_uInt16 nId)815cdf0e10cSrcweir SvxULSpaceItem::SvxULSpaceItem( const sal_uInt16 nUp, const sal_uInt16 nLow,
816cdf0e10cSrcweir const sal_uInt16 nId ) :
817cdf0e10cSrcweir
818cdf0e10cSrcweir SfxPoolItem( nId ),
819cdf0e10cSrcweir
820cdf0e10cSrcweir nUpper( nUp ),
821cdf0e10cSrcweir nLower( nLow ),
822cdf0e10cSrcweir nPropUpper( 100 ),
823cdf0e10cSrcweir nPropLower( 100 )
824cdf0e10cSrcweir {
825cdf0e10cSrcweir }
826cdf0e10cSrcweir
827cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const828cdf0e10cSrcweir sal_Bool SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
829cdf0e10cSrcweir {
830cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
831cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
832cdf0e10cSrcweir switch( nMemberId )
833cdf0e10cSrcweir {
834cdf0e10cSrcweir // jetzt alles signed
835cdf0e10cSrcweir case 0:
836cdf0e10cSrcweir {
837cdf0e10cSrcweir ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
838cdf0e10cSrcweir aUpperLowerMarginScale.Upper = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper);
839cdf0e10cSrcweir aUpperLowerMarginScale.Lower = (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nPropUpper);
840cdf0e10cSrcweir aUpperLowerMarginScale.ScaleUpper = (sal_Int16)nPropUpper;
841cdf0e10cSrcweir aUpperLowerMarginScale.ScaleLower = (sal_Int16)nPropLower;
842cdf0e10cSrcweir rVal <<= aUpperLowerMarginScale;
843cdf0e10cSrcweir break;
844cdf0e10cSrcweir }
845cdf0e10cSrcweir case MID_UP_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nUpper) : nUpper); break;
846cdf0e10cSrcweir case MID_LO_MARGIN: rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nLower) : nLower); break;
847cdf0e10cSrcweir case MID_UP_REL_MARGIN: rVal <<= (sal_Int16) nPropUpper; break;
848cdf0e10cSrcweir case MID_LO_REL_MARGIN: rVal <<= (sal_Int16) nPropLower; break;
849cdf0e10cSrcweir }
850cdf0e10cSrcweir return sal_True;
851cdf0e10cSrcweir }
852cdf0e10cSrcweir
853cdf0e10cSrcweir // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)854cdf0e10cSrcweir sal_Bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
857cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
858cdf0e10cSrcweir sal_Int32 nVal = 0;
859cdf0e10cSrcweir switch( nMemberId )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir case 0:
862cdf0e10cSrcweir {
863cdf0e10cSrcweir ::com::sun::star::frame::status::UpperLowerMarginScale aUpperLowerMarginScale;
864cdf0e10cSrcweir if ( !(rVal >>= aUpperLowerMarginScale ))
865cdf0e10cSrcweir return sal_False;
866cdf0e10cSrcweir {
867cdf0e10cSrcweir SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Upper ) : aUpperLowerMarginScale.Upper));
868cdf0e10cSrcweir SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP( aUpperLowerMarginScale.Lower ) : aUpperLowerMarginScale.Lower));
869cdf0e10cSrcweir if( aUpperLowerMarginScale.ScaleUpper > 1 )
870cdf0e10cSrcweir nPropUpper = aUpperLowerMarginScale.ScaleUpper;
871cdf0e10cSrcweir if( aUpperLowerMarginScale.ScaleLower > 1 )
872cdf0e10cSrcweir nPropUpper = aUpperLowerMarginScale.ScaleLower;
873cdf0e10cSrcweir }
874cdf0e10cSrcweir }
875cdf0e10cSrcweir
876cdf0e10cSrcweir case MID_UP_MARGIN :
877cdf0e10cSrcweir if(!(rVal >>= nVal) || nVal < 0)
878cdf0e10cSrcweir return sal_False;
879cdf0e10cSrcweir SetUpper((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
880cdf0e10cSrcweir break;
881cdf0e10cSrcweir case MID_LO_MARGIN :
882cdf0e10cSrcweir if(!(rVal >>= nVal) || nVal < 0)
883cdf0e10cSrcweir return sal_False;
884cdf0e10cSrcweir SetLower((sal_uInt16)(bConvert ? MM100_TO_TWIP(nVal) : nVal));
885cdf0e10cSrcweir break;
886cdf0e10cSrcweir case MID_UP_REL_MARGIN:
887cdf0e10cSrcweir case MID_LO_REL_MARGIN:
888cdf0e10cSrcweir {
889cdf0e10cSrcweir sal_Int32 nRel = 0;
890cdf0e10cSrcweir if((rVal >>= nRel) && nRel > 1 )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir if(MID_UP_REL_MARGIN == nMemberId)
893cdf0e10cSrcweir nPropUpper = (sal_uInt16)nRel;
894cdf0e10cSrcweir else
895cdf0e10cSrcweir nPropLower = (sal_uInt16)nRel;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir else
898cdf0e10cSrcweir return sal_False;
899cdf0e10cSrcweir }
900cdf0e10cSrcweir break;
901cdf0e10cSrcweir
902cdf0e10cSrcweir
903cdf0e10cSrcweir default:
904cdf0e10cSrcweir DBG_ERROR("unknown MemberId");
905cdf0e10cSrcweir return sal_False;
906cdf0e10cSrcweir }
907cdf0e10cSrcweir return sal_True;
908cdf0e10cSrcweir }
909cdf0e10cSrcweir
910cdf0e10cSrcweir // -----------------------------------------------------------------------
911cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const912cdf0e10cSrcweir int SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const
913cdf0e10cSrcweir {
914cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
915cdf0e10cSrcweir
916cdf0e10cSrcweir return ( nUpper == ( (SvxULSpaceItem&)rAttr ).nUpper &&
917cdf0e10cSrcweir nLower == ( (SvxULSpaceItem&)rAttr ).nLower &&
918cdf0e10cSrcweir nPropUpper == ( (SvxULSpaceItem&)rAttr ).nPropUpper &&
919cdf0e10cSrcweir nPropLower == ( (SvxULSpaceItem&)rAttr ).nPropLower );
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
922cdf0e10cSrcweir // -----------------------------------------------------------------------
923cdf0e10cSrcweir
Clone(SfxItemPool *) const924cdf0e10cSrcweir SfxPoolItem* SvxULSpaceItem::Clone( SfxItemPool* ) const
925cdf0e10cSrcweir {
926cdf0e10cSrcweir return new SvxULSpaceItem( *this );
927cdf0e10cSrcweir }
928cdf0e10cSrcweir
929cdf0e10cSrcweir //------------------------------------------------------------------------
930cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const931cdf0e10cSrcweir SfxItemPresentation SvxULSpaceItem::GetPresentation
932cdf0e10cSrcweir (
933cdf0e10cSrcweir SfxItemPresentation ePres,
934cdf0e10cSrcweir SfxMapUnit eCoreUnit,
935cdf0e10cSrcweir SfxMapUnit ePresUnit,
936cdf0e10cSrcweir XubString& rText, const IntlWrapper *pIntl
937cdf0e10cSrcweir ) const
938cdf0e10cSrcweir {
939cdf0e10cSrcweir #ifndef SVX_LIGHT
940cdf0e10cSrcweir switch ( ePres )
941cdf0e10cSrcweir {
942cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
943cdf0e10cSrcweir rText.Erase();
944cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
945cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
946cdf0e10cSrcweir {
947cdf0e10cSrcweir if ( 100 != nPropUpper )
948cdf0e10cSrcweir ( rText = String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
949cdf0e10cSrcweir else
950cdf0e10cSrcweir rText = GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
951cdf0e10cSrcweir rText += cpDelim;
952cdf0e10cSrcweir if ( 100 != nPropLower )
953cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
954cdf0e10cSrcweir else
955cdf0e10cSrcweir rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
956cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
957cdf0e10cSrcweir }
958cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
959cdf0e10cSrcweir {
960cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_ULSPACE_UPPER);
961cdf0e10cSrcweir if ( 100 != nPropUpper )
962cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropUpper )) += sal_Unicode('%');
963cdf0e10cSrcweir else
964cdf0e10cSrcweir {
965cdf0e10cSrcweir rText += GetMetricText( (long)nUpper, eCoreUnit, ePresUnit, pIntl );
966*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
967cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
968cdf0e10cSrcweir }
969cdf0e10cSrcweir rText += cpDelim;
970cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_ULSPACE_LOWER);
971cdf0e10cSrcweir if ( 100 != nPropLower )
972cdf0e10cSrcweir ( rText += String::CreateFromInt32( nPropLower )) += sal_Unicode('%');
973cdf0e10cSrcweir else
974cdf0e10cSrcweir {
975cdf0e10cSrcweir rText += GetMetricText( (long)nLower, eCoreUnit, ePresUnit, pIntl );
976*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
977cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
978cdf0e10cSrcweir }
979cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE;
980cdf0e10cSrcweir }
981cdf0e10cSrcweir default: ;//prevent warning
982cdf0e10cSrcweir }
983cdf0e10cSrcweir #endif
984cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
985cdf0e10cSrcweir }
986cdf0e10cSrcweir
987cdf0e10cSrcweir // -----------------------------------------------------------------------
988cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const989cdf0e10cSrcweir SvStream& SvxULSpaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
990cdf0e10cSrcweir {
991cdf0e10cSrcweir rStrm << GetUpper()
992cdf0e10cSrcweir << GetPropUpper()
993cdf0e10cSrcweir << GetLower()
994cdf0e10cSrcweir << GetPropLower();
995cdf0e10cSrcweir return rStrm;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir
998cdf0e10cSrcweir // -----------------------------------------------------------------------
999cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16 nVersion) const1000cdf0e10cSrcweir SfxPoolItem* SvxULSpaceItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir sal_uInt16 upper, lower, nPL = 0, nPU = 0;
1003cdf0e10cSrcweir
1004cdf0e10cSrcweir if ( nVersion == ULSPACE_16_VERSION )
1005cdf0e10cSrcweir rStrm >> upper >> nPU >> lower >> nPL;
1006cdf0e10cSrcweir else
1007cdf0e10cSrcweir {
1008cdf0e10cSrcweir sal_Int8 nU, nL;
1009cdf0e10cSrcweir rStrm >> upper >> nU >> lower >> nL;
1010cdf0e10cSrcweir nPL = (sal_uInt16)nL;
1011cdf0e10cSrcweir nPU = (sal_uInt16)nU;
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir
1014cdf0e10cSrcweir SvxULSpaceItem* pAttr = new SvxULSpaceItem( Which() );
1015cdf0e10cSrcweir pAttr->SetUpperValue( upper );
1016cdf0e10cSrcweir pAttr->SetLowerValue( lower );
1017cdf0e10cSrcweir pAttr->SetPropUpper( nPU );
1018cdf0e10cSrcweir pAttr->SetPropLower( nPL );
1019cdf0e10cSrcweir return pAttr;
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir // -----------------------------------------------------------------------
1023cdf0e10cSrcweir
GetVersion(sal_uInt16) const1024cdf0e10cSrcweir sal_uInt16 SvxULSpaceItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir return ULSPACE_16_VERSION;
1027cdf0e10cSrcweir }
1028cdf0e10cSrcweir
1029cdf0e10cSrcweir // -----------------------------------------------------------------------
1030cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)1031cdf0e10cSrcweir int SvxULSpaceItem::ScaleMetrics( long nMult, long nDiv )
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir nUpper = (sal_uInt16)Scale( nUpper, nMult, nDiv );
1034cdf0e10cSrcweir nLower = (sal_uInt16)Scale( nLower, nMult, nDiv );
1035cdf0e10cSrcweir return 1;
1036cdf0e10cSrcweir }
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir // -----------------------------------------------------------------------
1039cdf0e10cSrcweir
HasMetrics() const1040cdf0e10cSrcweir int SvxULSpaceItem::HasMetrics() const
1041cdf0e10cSrcweir {
1042cdf0e10cSrcweir return 1;
1043cdf0e10cSrcweir }
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir // class SvxPrintItem ----------------------------------------------------
1047cdf0e10cSrcweir
Clone(SfxItemPool *) const1048cdf0e10cSrcweir SfxPoolItem* SvxPrintItem::Clone( SfxItemPool* ) const
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir return new SvxPrintItem( *this );
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir
1053cdf0e10cSrcweir // -----------------------------------------------------------------------
1054cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const1055cdf0e10cSrcweir SvStream& SvxPrintItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1056cdf0e10cSrcweir {
1057cdf0e10cSrcweir rStrm << (sal_Int8)GetValue();
1058cdf0e10cSrcweir return rStrm;
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir // -----------------------------------------------------------------------
1062cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const1063cdf0e10cSrcweir SfxPoolItem* SvxPrintItem::Create( SvStream& rStrm, sal_uInt16 ) const
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir sal_Int8 bIsPrint;
1066cdf0e10cSrcweir rStrm >> bIsPrint;
1067cdf0e10cSrcweir return new SvxPrintItem( Which(), sal_Bool( bIsPrint != 0 ) );
1068cdf0e10cSrcweir }
1069cdf0e10cSrcweir
1070cdf0e10cSrcweir //------------------------------------------------------------------------
1071cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1072cdf0e10cSrcweir SfxItemPresentation SvxPrintItem::GetPresentation
1073cdf0e10cSrcweir (
1074cdf0e10cSrcweir SfxItemPresentation ePres,
1075cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
1076cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
1077cdf0e10cSrcweir XubString& rText, const IntlWrapper *
1078cdf0e10cSrcweir ) const
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir #ifndef SVX_LIGHT
1081cdf0e10cSrcweir switch ( ePres )
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
1084cdf0e10cSrcweir rText.Erase();
1085cdf0e10cSrcweir return ePres;
1086cdf0e10cSrcweir
1087cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
1088cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_PRINT_FALSE;
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir if ( GetValue() )
1093cdf0e10cSrcweir nId = RID_SVXITEMS_PRINT_TRUE;
1094cdf0e10cSrcweir rText = EE_RESSTR(nId);
1095cdf0e10cSrcweir return ePres;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir default: ;//prevent warning
1098cdf0e10cSrcweir }
1099cdf0e10cSrcweir #endif // !SVX_LIGHT
1100cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
1101cdf0e10cSrcweir }
1102cdf0e10cSrcweir
1103cdf0e10cSrcweir // class SvxOpaqueItem ---------------------------------------------------
1104cdf0e10cSrcweir
Clone(SfxItemPool *) const1105cdf0e10cSrcweir SfxPoolItem* SvxOpaqueItem::Clone( SfxItemPool* ) const
1106cdf0e10cSrcweir {
1107cdf0e10cSrcweir return new SvxOpaqueItem( *this );
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir
1110cdf0e10cSrcweir // -----------------------------------------------------------------------
1111cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const1112cdf0e10cSrcweir SvStream& SvxOpaqueItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir rStrm << (sal_Int8)GetValue();
1115cdf0e10cSrcweir return rStrm;
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir // -----------------------------------------------------------------------
1119cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const1120cdf0e10cSrcweir SfxPoolItem* SvxOpaqueItem::Create( SvStream& rStrm, sal_uInt16 ) const
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir sal_Int8 bIsOpaque;
1123cdf0e10cSrcweir rStrm >> bIsOpaque;
1124cdf0e10cSrcweir return new SvxOpaqueItem( Which(), sal_Bool( bIsOpaque != 0 ) );
1125cdf0e10cSrcweir }
1126cdf0e10cSrcweir
1127cdf0e10cSrcweir //------------------------------------------------------------------------
1128cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1129cdf0e10cSrcweir SfxItemPresentation SvxOpaqueItem::GetPresentation
1130cdf0e10cSrcweir (
1131cdf0e10cSrcweir SfxItemPresentation ePres,
1132cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
1133cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
1134cdf0e10cSrcweir XubString& rText, const IntlWrapper *
1135cdf0e10cSrcweir ) const
1136cdf0e10cSrcweir {
1137cdf0e10cSrcweir #ifndef SVX_LIGHT
1138cdf0e10cSrcweir switch ( ePres )
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
1141cdf0e10cSrcweir rText.Erase();
1142cdf0e10cSrcweir return ePres;
1143cdf0e10cSrcweir
1144cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
1145cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
1146cdf0e10cSrcweir {
1147cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_OPAQUE_FALSE;
1148cdf0e10cSrcweir
1149cdf0e10cSrcweir if ( GetValue() )
1150cdf0e10cSrcweir nId = RID_SVXITEMS_OPAQUE_TRUE;
1151cdf0e10cSrcweir rText = EE_RESSTR(nId);
1152cdf0e10cSrcweir return ePres;
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir default: ;//prevent warning
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir #endif // !SVX_LIGHT
1157cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir
1160cdf0e10cSrcweir // class SvxProtectItem --------------------------------------------------
1161cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const1162cdf0e10cSrcweir int SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const
1163cdf0e10cSrcweir {
1164cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1165cdf0e10cSrcweir
1166cdf0e10cSrcweir return ( bCntnt == ( (SvxProtectItem&)rAttr ).bCntnt &&
1167cdf0e10cSrcweir bSize == ( (SvxProtectItem&)rAttr ).bSize &&
1168cdf0e10cSrcweir bPos == ( (SvxProtectItem&)rAttr ).bPos );
1169cdf0e10cSrcweir }
1170cdf0e10cSrcweir
1171cdf0e10cSrcweir /*-----------------16.03.98 12:42-------------------
1172cdf0e10cSrcweir --------------------------------------------------*/
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1173cdf0e10cSrcweir sal_Bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1174cdf0e10cSrcweir {
1175cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1176cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1177cdf0e10cSrcweir sal_Bool bValue;
1178cdf0e10cSrcweir switch(nMemberId)
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir case MID_PROTECT_CONTENT : bValue = bCntnt; break;
1181cdf0e10cSrcweir case MID_PROTECT_SIZE : bValue = bSize; break;
1182cdf0e10cSrcweir case MID_PROTECT_POSITION: bValue = bPos; break;
1183cdf0e10cSrcweir default:
1184cdf0e10cSrcweir DBG_ERROR("falsche MemberId");
1185cdf0e10cSrcweir return sal_False;
1186cdf0e10cSrcweir }
1187cdf0e10cSrcweir
1188cdf0e10cSrcweir rVal = Bool2Any( bValue );
1189cdf0e10cSrcweir return sal_True;
1190cdf0e10cSrcweir }
1191cdf0e10cSrcweir /*-----------------16.03.98 12:42-------------------
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir --------------------------------------------------*/
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1194cdf0e10cSrcweir sal_Bool SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1197cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1198cdf0e10cSrcweir sal_Bool bVal( Any2Bool(rVal) );
1199cdf0e10cSrcweir switch(nMemberId)
1200cdf0e10cSrcweir {
1201cdf0e10cSrcweir case MID_PROTECT_CONTENT : bCntnt = bVal; break;
1202cdf0e10cSrcweir case MID_PROTECT_SIZE : bSize = bVal; break;
1203cdf0e10cSrcweir case MID_PROTECT_POSITION: bPos = bVal; break;
1204cdf0e10cSrcweir default:
1205cdf0e10cSrcweir DBG_ERROR("falsche MemberId");
1206cdf0e10cSrcweir return sal_False;
1207cdf0e10cSrcweir }
1208cdf0e10cSrcweir return sal_True;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir
1211cdf0e10cSrcweir // -----------------------------------------------------------------------
1212cdf0e10cSrcweir
Clone(SfxItemPool *) const1213cdf0e10cSrcweir SfxPoolItem* SvxProtectItem::Clone( SfxItemPool* ) const
1214cdf0e10cSrcweir {
1215cdf0e10cSrcweir return new SvxProtectItem( *this );
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir
1218cdf0e10cSrcweir //------------------------------------------------------------------------
1219cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const1220cdf0e10cSrcweir SfxItemPresentation SvxProtectItem::GetPresentation
1221cdf0e10cSrcweir (
1222cdf0e10cSrcweir SfxItemPresentation ePres,
1223cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
1224cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
1225cdf0e10cSrcweir XubString& rText, const IntlWrapper *
1226cdf0e10cSrcweir ) const
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir #ifndef SVX_LIGHT
1229cdf0e10cSrcweir switch ( ePres )
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
1232cdf0e10cSrcweir rText.Erase();
1233cdf0e10cSrcweir return ePres;
1234cdf0e10cSrcweir
1235cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
1236cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_PROT_CONTENT_FALSE;
1239cdf0e10cSrcweir
1240cdf0e10cSrcweir if ( bCntnt )
1241cdf0e10cSrcweir nId = RID_SVXITEMS_PROT_CONTENT_TRUE;
1242cdf0e10cSrcweir rText = EE_RESSTR(nId);
1243cdf0e10cSrcweir rText += cpDelim;
1244cdf0e10cSrcweir nId = RID_SVXITEMS_PROT_SIZE_FALSE;
1245cdf0e10cSrcweir
1246cdf0e10cSrcweir if ( bSize )
1247cdf0e10cSrcweir nId = RID_SVXITEMS_PROT_SIZE_TRUE;
1248cdf0e10cSrcweir rText += EE_RESSTR(nId);
1249cdf0e10cSrcweir rText += cpDelim;
1250cdf0e10cSrcweir nId = RID_SVXITEMS_PROT_POS_FALSE;
1251cdf0e10cSrcweir
1252cdf0e10cSrcweir if ( bPos )
1253cdf0e10cSrcweir nId = RID_SVXITEMS_PROT_POS_TRUE;
1254cdf0e10cSrcweir rText += EE_RESSTR(nId);
1255cdf0e10cSrcweir return ePres;
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir default: ;//prevent warning
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir #endif // !SVX_LIGHT
1260cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
1261cdf0e10cSrcweir }
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir // -----------------------------------------------------------------------
1264cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const1265cdf0e10cSrcweir SvStream& SvxProtectItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1266cdf0e10cSrcweir {
1267cdf0e10cSrcweir sal_Int8 cProt = 0;
1268cdf0e10cSrcweir if( IsPosProtected() ) cProt |= 0x01;
1269cdf0e10cSrcweir if( IsSizeProtected() ) cProt |= 0x02;
1270cdf0e10cSrcweir if( IsCntntProtected() ) cProt |= 0x04;
1271cdf0e10cSrcweir rStrm << (sal_Int8) cProt;
1272cdf0e10cSrcweir return rStrm;
1273cdf0e10cSrcweir }
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir // -----------------------------------------------------------------------
1276cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const1277cdf0e10cSrcweir SfxPoolItem* SvxProtectItem::Create( SvStream& rStrm, sal_uInt16 ) const
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir sal_Int8 cFlags;
1280cdf0e10cSrcweir rStrm >> cFlags;
1281cdf0e10cSrcweir SvxProtectItem* pAttr = new SvxProtectItem( Which() );
1282cdf0e10cSrcweir pAttr->SetPosProtect( sal_Bool( ( cFlags & 0x01 ) != 0 ) );
1283cdf0e10cSrcweir pAttr->SetSizeProtect( sal_Bool( ( cFlags & 0x02 ) != 0 ) );
1284cdf0e10cSrcweir pAttr->SetCntntProtect( sal_Bool( ( cFlags & 0x04 ) != 0 ) );
1285cdf0e10cSrcweir return pAttr;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir // class SvxShadowItem ---------------------------------------------------
1289cdf0e10cSrcweir
SvxShadowItem(const sal_uInt16 nId,const Color * pColor,const sal_uInt16 nW,const SvxShadowLocation eLoc)1290cdf0e10cSrcweir SvxShadowItem::SvxShadowItem( const sal_uInt16 nId,
1291cdf0e10cSrcweir const Color *pColor, const sal_uInt16 nW,
1292cdf0e10cSrcweir const SvxShadowLocation eLoc ) :
1293cdf0e10cSrcweir SfxEnumItemInterface( nId ),
1294cdf0e10cSrcweir aShadowColor(COL_GRAY),
1295cdf0e10cSrcweir nWidth ( nW ),
1296cdf0e10cSrcweir eLocation ( eLoc )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir if ( pColor )
1299cdf0e10cSrcweir aShadowColor = *pColor;
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir
1302cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1303cdf0e10cSrcweir sal_Bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1306cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1307cdf0e10cSrcweir
1308cdf0e10cSrcweir table::ShadowFormat aShadow;
1309cdf0e10cSrcweir table::ShadowLocation eSet = table::ShadowLocation_NONE;
1310cdf0e10cSrcweir switch( eLocation )
1311cdf0e10cSrcweir {
1312cdf0e10cSrcweir case SVX_SHADOW_TOPLEFT : eSet = table::ShadowLocation_TOP_LEFT ; break;
1313cdf0e10cSrcweir case SVX_SHADOW_TOPRIGHT : eSet = table::ShadowLocation_TOP_RIGHT ; break;
1314cdf0e10cSrcweir case SVX_SHADOW_BOTTOMLEFT : eSet = table::ShadowLocation_BOTTOM_LEFT ; break;
1315cdf0e10cSrcweir case SVX_SHADOW_BOTTOMRIGHT: eSet = table::ShadowLocation_BOTTOM_RIGHT; break;
1316cdf0e10cSrcweir default: ;//prevent warning
1317cdf0e10cSrcweir }
1318cdf0e10cSrcweir aShadow.Location = eSet;
1319cdf0e10cSrcweir aShadow.ShadowWidth = bConvert ? TWIP_TO_MM100_UNSIGNED(nWidth) : nWidth;
1320cdf0e10cSrcweir aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
1321cdf0e10cSrcweir aShadow.Color = aShadowColor.GetRGBColor();
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir switch ( nMemberId )
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir case MID_LOCATION: rVal <<= aShadow.Location; break;
1326cdf0e10cSrcweir case MID_WIDTH: rVal <<= aShadow.ShadowWidth; break;
1327cdf0e10cSrcweir case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break;
1328cdf0e10cSrcweir case MID_BG_COLOR: rVal <<= aShadow.Color; break;
1329cdf0e10cSrcweir case 0: rVal <<= aShadow; break;
1330cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!"); return sal_False;
1331cdf0e10cSrcweir }
1332cdf0e10cSrcweir
1333cdf0e10cSrcweir return sal_True;
1334cdf0e10cSrcweir }
1335cdf0e10cSrcweir // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1336cdf0e10cSrcweir sal_Bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1337cdf0e10cSrcweir {
1338cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1339cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1340cdf0e10cSrcweir
1341cdf0e10cSrcweir table::ShadowFormat aShadow;
1342cdf0e10cSrcweir uno::Any aAny;
1343cdf0e10cSrcweir sal_Bool bRet = QueryValue( aAny, bConvert ? CONVERT_TWIPS : 0 ) && ( aAny >>= aShadow );
1344cdf0e10cSrcweir switch ( nMemberId )
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir case MID_LOCATION:
1347cdf0e10cSrcweir {
1348cdf0e10cSrcweir bRet = (rVal >>= aShadow.Location);
1349cdf0e10cSrcweir if ( !bRet )
1350cdf0e10cSrcweir {
1351cdf0e10cSrcweir sal_Int16 nVal = 0;
1352cdf0e10cSrcweir bRet = (rVal >>= nVal);
1353cdf0e10cSrcweir aShadow.Location = (table::ShadowLocation) nVal;
1354cdf0e10cSrcweir }
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir break;
1357cdf0e10cSrcweir }
1358cdf0e10cSrcweir
1359cdf0e10cSrcweir case MID_WIDTH: rVal >>= aShadow.ShadowWidth; break;
1360cdf0e10cSrcweir case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break;
1361cdf0e10cSrcweir case MID_BG_COLOR: rVal >>= aShadow.Color; break;
1362cdf0e10cSrcweir case 0: rVal >>= aShadow; break;
1363cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!"); return sal_False;
1364cdf0e10cSrcweir }
1365cdf0e10cSrcweir
1366cdf0e10cSrcweir if ( bRet )
1367cdf0e10cSrcweir {
1368cdf0e10cSrcweir // SvxShadowLocation eSet = SVX_SHADOW_NONE;
1369cdf0e10cSrcweir switch( aShadow.Location )
1370cdf0e10cSrcweir {
1371cdf0e10cSrcweir case table::ShadowLocation_TOP_LEFT : eLocation = SVX_SHADOW_TOPLEFT; break;
1372cdf0e10cSrcweir case table::ShadowLocation_TOP_RIGHT : eLocation = SVX_SHADOW_TOPRIGHT; break;
1373cdf0e10cSrcweir case table::ShadowLocation_BOTTOM_LEFT : eLocation = SVX_SHADOW_BOTTOMLEFT ; break;
1374cdf0e10cSrcweir case table::ShadowLocation_BOTTOM_RIGHT: eLocation = SVX_SHADOW_BOTTOMRIGHT; break;
1375cdf0e10cSrcweir default: ;//prevent warning
1376cdf0e10cSrcweir }
1377cdf0e10cSrcweir
1378cdf0e10cSrcweir nWidth = bConvert ? MM100_TO_TWIP(aShadow.ShadowWidth) : aShadow.ShadowWidth;
1379cdf0e10cSrcweir Color aSet(aShadow.Color);
1380cdf0e10cSrcweir aSet.SetTransparency(aShadow.IsTransparent ? 0xff : 0);
1381cdf0e10cSrcweir aShadowColor = aSet;
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir
1384cdf0e10cSrcweir return bRet;
1385cdf0e10cSrcweir }
1386cdf0e10cSrcweir
1387cdf0e10cSrcweir // -----------------------------------------------------------------------
1388cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const1389cdf0e10cSrcweir int SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
1390cdf0e10cSrcweir {
1391cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1392cdf0e10cSrcweir
1393cdf0e10cSrcweir return ( ( aShadowColor == ( (SvxShadowItem&)rAttr ).aShadowColor ) &&
1394cdf0e10cSrcweir ( nWidth == ( (SvxShadowItem&)rAttr ).GetWidth() ) &&
1395cdf0e10cSrcweir ( eLocation == ( (SvxShadowItem&)rAttr ).GetLocation() ) );
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir
1398cdf0e10cSrcweir // -----------------------------------------------------------------------
1399cdf0e10cSrcweir
Clone(SfxItemPool *) const1400cdf0e10cSrcweir SfxPoolItem* SvxShadowItem::Clone( SfxItemPool* ) const
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir return new SvxShadowItem( *this );
1403cdf0e10cSrcweir }
1404cdf0e10cSrcweir
1405cdf0e10cSrcweir // -----------------------------------------------------------------------
1406cdf0e10cSrcweir
CalcShadowSpace(sal_uInt16 nShadow) const1407cdf0e10cSrcweir sal_uInt16 SvxShadowItem::CalcShadowSpace( sal_uInt16 nShadow ) const
1408cdf0e10cSrcweir {
1409cdf0e10cSrcweir sal_uInt16 nSpace = 0;
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir switch ( nShadow )
1412cdf0e10cSrcweir {
1413cdf0e10cSrcweir case SHADOW_TOP:
1414cdf0e10cSrcweir if ( eLocation == SVX_SHADOW_TOPLEFT ||
1415cdf0e10cSrcweir eLocation == SVX_SHADOW_TOPRIGHT )
1416cdf0e10cSrcweir nSpace = nWidth;
1417cdf0e10cSrcweir break;
1418cdf0e10cSrcweir
1419cdf0e10cSrcweir case SHADOW_BOTTOM:
1420cdf0e10cSrcweir if ( eLocation == SVX_SHADOW_BOTTOMLEFT ||
1421cdf0e10cSrcweir eLocation == SVX_SHADOW_BOTTOMRIGHT )
1422cdf0e10cSrcweir nSpace = nWidth;
1423cdf0e10cSrcweir break;
1424cdf0e10cSrcweir
1425cdf0e10cSrcweir case SHADOW_LEFT:
1426cdf0e10cSrcweir if ( eLocation == SVX_SHADOW_TOPLEFT ||
1427cdf0e10cSrcweir eLocation == SVX_SHADOW_BOTTOMLEFT )
1428cdf0e10cSrcweir nSpace = nWidth;
1429cdf0e10cSrcweir break;
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir case SHADOW_RIGHT:
1432cdf0e10cSrcweir if ( eLocation == SVX_SHADOW_TOPRIGHT ||
1433cdf0e10cSrcweir eLocation == SVX_SHADOW_BOTTOMRIGHT )
1434cdf0e10cSrcweir nSpace = nWidth;
1435cdf0e10cSrcweir break;
1436cdf0e10cSrcweir
1437cdf0e10cSrcweir default:
1438cdf0e10cSrcweir DBG_ERROR( "wrong shadow" );
1439cdf0e10cSrcweir }
1440cdf0e10cSrcweir return nSpace;
1441cdf0e10cSrcweir }
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir //------------------------------------------------------------------------
1444cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const1445cdf0e10cSrcweir SfxItemPresentation SvxShadowItem::GetPresentation
1446cdf0e10cSrcweir (
1447cdf0e10cSrcweir SfxItemPresentation ePres,
1448cdf0e10cSrcweir SfxMapUnit eCoreUnit,
1449cdf0e10cSrcweir SfxMapUnit ePresUnit,
1450cdf0e10cSrcweir XubString& rText, const IntlWrapper *pIntl
1451cdf0e10cSrcweir ) const
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir #ifndef SVX_LIGHT
1454cdf0e10cSrcweir switch ( ePres )
1455cdf0e10cSrcweir {
1456cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
1457cdf0e10cSrcweir rText.Erase();
1458cdf0e10cSrcweir return ePres;
1459cdf0e10cSrcweir
1460cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
1461cdf0e10cSrcweir {
1462cdf0e10cSrcweir rText = ::GetColorString( aShadowColor );
1463cdf0e10cSrcweir rText += cpDelim;
1464cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1465cdf0e10cSrcweir
1466cdf0e10cSrcweir if ( aShadowColor.GetTransparency() )
1467cdf0e10cSrcweir nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1468cdf0e10cSrcweir rText += EE_RESSTR(nId);
1469cdf0e10cSrcweir rText += cpDelim;
1470cdf0e10cSrcweir rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1471cdf0e10cSrcweir rText += cpDelim;
1472cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1473cdf0e10cSrcweir return ePres;
1474cdf0e10cSrcweir }
1475cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_SHADOW_COMPLETE);
1478cdf0e10cSrcweir rText += ::GetColorString( aShadowColor );
1479cdf0e10cSrcweir rText += cpDelim;
1480cdf0e10cSrcweir
1481cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
1482cdf0e10cSrcweir if ( aShadowColor.GetTransparency() )
1483cdf0e10cSrcweir nId = RID_SVXITEMS_TRANSPARENT_TRUE;
1484cdf0e10cSrcweir rText += EE_RESSTR(nId);
1485cdf0e10cSrcweir rText += cpDelim;
1486cdf0e10cSrcweir rText += GetMetricText( (long)nWidth, eCoreUnit, ePresUnit, pIntl );
1487*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
1488cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
1489cdf0e10cSrcweir rText += cpDelim;
1490cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_SHADOW_BEGIN + eLocation);
1491cdf0e10cSrcweir return ePres;
1492cdf0e10cSrcweir }
1493cdf0e10cSrcweir default: ;//prevent warning
1494cdf0e10cSrcweir }
1495cdf0e10cSrcweir #endif
1496cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
1497cdf0e10cSrcweir }
1498cdf0e10cSrcweir
1499cdf0e10cSrcweir // -----------------------------------------------------------------------
1500cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const1501cdf0e10cSrcweir SvStream& SvxShadowItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
1502cdf0e10cSrcweir {
1503cdf0e10cSrcweir rStrm << (sal_Int8) GetLocation()
1504cdf0e10cSrcweir << (sal_uInt16) GetWidth()
1505cdf0e10cSrcweir << (sal_Bool)(aShadowColor.GetTransparency() > 0)
1506cdf0e10cSrcweir << GetColor()
1507cdf0e10cSrcweir << GetColor()
1508cdf0e10cSrcweir << (sal_Int8)(aShadowColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
1509cdf0e10cSrcweir return rStrm;
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir
1512cdf0e10cSrcweir // -----------------------------------------------------------------------
1513cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)1514cdf0e10cSrcweir int SvxShadowItem::ScaleMetrics( long nMult, long nDiv )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir nWidth = (sal_uInt16)Scale( nWidth, nMult, nDiv );
1517cdf0e10cSrcweir return 1;
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir
1520cdf0e10cSrcweir // -----------------------------------------------------------------------
1521cdf0e10cSrcweir
HasMetrics() const1522cdf0e10cSrcweir int SvxShadowItem::HasMetrics() const
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir return 1;
1525cdf0e10cSrcweir }
1526cdf0e10cSrcweir
1527cdf0e10cSrcweir // -----------------------------------------------------------------------
1528cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const1529cdf0e10cSrcweir SfxPoolItem* SvxShadowItem::Create( SvStream& rStrm, sal_uInt16 ) const
1530cdf0e10cSrcweir {
1531cdf0e10cSrcweir sal_Int8 cLoc;
1532cdf0e10cSrcweir sal_uInt16 _nWidth;
1533cdf0e10cSrcweir sal_Bool bTrans;
1534cdf0e10cSrcweir Color aColor;
1535cdf0e10cSrcweir Color aFillColor;
1536cdf0e10cSrcweir sal_Int8 nStyle;
1537cdf0e10cSrcweir rStrm >> cLoc >> _nWidth
1538cdf0e10cSrcweir >> bTrans >> aColor >> aFillColor >> nStyle;
1539cdf0e10cSrcweir aColor.SetTransparency(bTrans ? 0xff : 0);
1540cdf0e10cSrcweir return new SvxShadowItem( Which(), &aColor, _nWidth, (SvxShadowLocation)cLoc );
1541cdf0e10cSrcweir }
1542cdf0e10cSrcweir
1543cdf0e10cSrcweir // -----------------------------------------------------------------------
1544cdf0e10cSrcweir
GetValueCount() const1545cdf0e10cSrcweir sal_uInt16 SvxShadowItem::GetValueCount() const
1546cdf0e10cSrcweir {
1547cdf0e10cSrcweir return SVX_SHADOW_END; // SVX_SHADOW_BOTTOMRIGHT + 1
1548cdf0e10cSrcweir }
1549cdf0e10cSrcweir
1550cdf0e10cSrcweir // -----------------------------------------------------------------------
1551cdf0e10cSrcweir
GetValueTextByPos(sal_uInt16 nPos) const1552cdf0e10cSrcweir XubString SvxShadowItem::GetValueTextByPos( sal_uInt16 nPos ) const
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir DBG_ASSERT( nPos < SVX_SHADOW_END, "enum overflow!" );
1555cdf0e10cSrcweir return XubString( EditResId( RID_SVXITEMS_SHADOW_BEGIN + nPos ) );
1556cdf0e10cSrcweir }
1557cdf0e10cSrcweir
1558cdf0e10cSrcweir // -----------------------------------------------------------------------
1559cdf0e10cSrcweir
GetEnumValue() const1560cdf0e10cSrcweir sal_uInt16 SvxShadowItem::GetEnumValue() const
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir return (sal_uInt16)GetLocation();
1563cdf0e10cSrcweir }
1564cdf0e10cSrcweir
1565cdf0e10cSrcweir // -----------------------------------------------------------------------
1566cdf0e10cSrcweir
SetEnumValue(sal_uInt16 nVal)1567cdf0e10cSrcweir void SvxShadowItem::SetEnumValue( sal_uInt16 nVal )
1568cdf0e10cSrcweir {
1569cdf0e10cSrcweir SetLocation( (const SvxShadowLocation)nVal );
1570cdf0e10cSrcweir }
1571cdf0e10cSrcweir
1572cdf0e10cSrcweir // class SvxBorderLine --------------------------------------------------
1573cdf0e10cSrcweir
SvxBorderLine(const Color * pCol,sal_uInt16 nOut,sal_uInt16 nIn,sal_uInt16 nDist)1574cdf0e10cSrcweir SvxBorderLine::SvxBorderLine( const Color *pCol, sal_uInt16 nOut, sal_uInt16 nIn, sal_uInt16 nDist )
1575cdf0e10cSrcweir : nOutWidth( nOut )
1576cdf0e10cSrcweir , nInWidth ( nIn )
1577cdf0e10cSrcweir , nDistance( nDist )
1578cdf0e10cSrcweir {
1579cdf0e10cSrcweir if ( pCol )
1580cdf0e10cSrcweir aColor = *pCol;
1581cdf0e10cSrcweir }
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir // -----------------------------------------------------------------------
1584cdf0e10cSrcweir
SvxBorderLine(const SvxBorderLine & r)1585cdf0e10cSrcweir SvxBorderLine::SvxBorderLine( const SvxBorderLine& r )
1586cdf0e10cSrcweir {
1587cdf0e10cSrcweir *this = r;
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir
1590cdf0e10cSrcweir // -----------------------------------------------------------------------
1591cdf0e10cSrcweir
operator =(const SvxBorderLine & r)1592cdf0e10cSrcweir SvxBorderLine& SvxBorderLine::operator=( const SvxBorderLine& r )
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir aColor = r.aColor;
1595cdf0e10cSrcweir nOutWidth = r.nOutWidth;
1596cdf0e10cSrcweir nInWidth = r.nInWidth;
1597cdf0e10cSrcweir nDistance = r.nDistance;
1598cdf0e10cSrcweir return *this;
1599cdf0e10cSrcweir }
1600cdf0e10cSrcweir
1601cdf0e10cSrcweir // -----------------------------------------------------------------------
1602cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)1603cdf0e10cSrcweir void SvxBorderLine::ScaleMetrics( long nMult, long nDiv )
1604cdf0e10cSrcweir {
1605cdf0e10cSrcweir nOutWidth = (sal_uInt16)Scale( nOutWidth, nMult, nDiv );
1606cdf0e10cSrcweir nInWidth = (sal_uInt16)Scale( nInWidth, nMult, nDiv );
1607cdf0e10cSrcweir nDistance = (sal_uInt16)Scale( nDistance, nMult, nDiv );
1608cdf0e10cSrcweir }
1609cdf0e10cSrcweir
1610cdf0e10cSrcweir // -----------------------------------------------------------------------
1611cdf0e10cSrcweir
operator ==(const SvxBorderLine & rCmp) const1612cdf0e10cSrcweir sal_Bool SvxBorderLine::operator==( const SvxBorderLine& rCmp ) const
1613cdf0e10cSrcweir {
1614cdf0e10cSrcweir return ( ( aColor == rCmp.GetColor() ) &&
1615cdf0e10cSrcweir ( nInWidth == rCmp.GetInWidth() ) &&
1616cdf0e10cSrcweir ( nOutWidth == rCmp.GetOutWidth() ) &&
1617cdf0e10cSrcweir ( nDistance == rCmp.GetDistance() ) );
1618cdf0e10cSrcweir }
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir // -----------------------------------------------------------------------
1621cdf0e10cSrcweir
GetValueString(SfxMapUnit eSrcUnit,SfxMapUnit eDestUnit,const IntlWrapper * pIntl,sal_Bool bMetricStr) const1622cdf0e10cSrcweir XubString SvxBorderLine::GetValueString( SfxMapUnit eSrcUnit,
1623cdf0e10cSrcweir SfxMapUnit eDestUnit,
1624cdf0e10cSrcweir const IntlWrapper* pIntl,
1625cdf0e10cSrcweir sal_Bool bMetricStr) const
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir #ifndef SVX_LIGHT
1628cdf0e10cSrcweir sal_uInt16 nResId = 0;
1629cdf0e10cSrcweir
1630cdf0e10cSrcweir if ( 0 == nDistance )
1631cdf0e10cSrcweir {
1632cdf0e10cSrcweir // einfach Linie
1633cdf0e10cSrcweir if ( DEF_LINE_WIDTH_0 == nOutWidth )
1634cdf0e10cSrcweir nResId = RID_SINGLE_LINE0;
1635cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_1 == nOutWidth )
1636cdf0e10cSrcweir nResId = RID_SINGLE_LINE1;
1637cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nOutWidth )
1638cdf0e10cSrcweir nResId = RID_SINGLE_LINE2;
1639cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_3 == nOutWidth )
1640cdf0e10cSrcweir nResId = RID_SINGLE_LINE3;
1641cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_4 == nOutWidth )
1642cdf0e10cSrcweir nResId = RID_SINGLE_LINE4;
1643cdf0e10cSrcweir }
1644cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_1 == nDistance )
1645cdf0e10cSrcweir {
1646cdf0e10cSrcweir // doppelte Linie, kleiner Abstand
1647cdf0e10cSrcweir if ( DEF_LINE_WIDTH_0 == nOutWidth && DEF_LINE_WIDTH_0 == nInWidth )
1648cdf0e10cSrcweir nResId = RID_DOUBLE_LINE0;
1649cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1650cdf0e10cSrcweir DEF_LINE_WIDTH_1 == nInWidth )
1651cdf0e10cSrcweir nResId = RID_DOUBLE_LINE2;
1652cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1653cdf0e10cSrcweir DEF_LINE_WIDTH_2 == nInWidth )
1654cdf0e10cSrcweir nResId = RID_DOUBLE_LINE8;
1655cdf0e10cSrcweir }
1656cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nDistance )
1657cdf0e10cSrcweir {
1658cdf0e10cSrcweir // doppelte Linie, gro\ser Abstand
1659cdf0e10cSrcweir if ( DEF_LINE_WIDTH_0 == nOutWidth && DEF_LINE_WIDTH_0 == nInWidth )
1660cdf0e10cSrcweir nResId = RID_DOUBLE_LINE1;
1661cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1662cdf0e10cSrcweir DEF_LINE_WIDTH_2 == nInWidth )
1663cdf0e10cSrcweir nResId = RID_DOUBLE_LINE3;
1664cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_1 == nOutWidth &&
1665cdf0e10cSrcweir DEF_LINE_WIDTH_0 == nInWidth )
1666cdf0e10cSrcweir nResId = RID_DOUBLE_LINE4;
1667cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1668cdf0e10cSrcweir DEF_LINE_WIDTH_0 == nInWidth )
1669cdf0e10cSrcweir nResId = RID_DOUBLE_LINE5;
1670cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_3 == nOutWidth &&
1671cdf0e10cSrcweir DEF_LINE_WIDTH_0 == nInWidth )
1672cdf0e10cSrcweir nResId = RID_DOUBLE_LINE6;
1673cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1674cdf0e10cSrcweir DEF_LINE_WIDTH_1 == nInWidth )
1675cdf0e10cSrcweir nResId = RID_DOUBLE_LINE7;
1676cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_3 == nOutWidth &&
1677cdf0e10cSrcweir DEF_LINE_WIDTH_2 == nInWidth )
1678cdf0e10cSrcweir nResId = RID_DOUBLE_LINE9;
1679cdf0e10cSrcweir else if ( DEF_LINE_WIDTH_2 == nOutWidth &&
1680cdf0e10cSrcweir DEF_LINE_WIDTH_3 == nInWidth )
1681cdf0e10cSrcweir nResId = RID_DOUBLE_LINE10;
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir String aStr;
1684cdf0e10cSrcweir aStr += sal_Unicode('(');
1685cdf0e10cSrcweir aStr += ::GetColorString( aColor );
1686cdf0e10cSrcweir aStr += cpDelim;
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir if ( nResId )
1689cdf0e10cSrcweir aStr += EE_RESSTR(nResId);
1690cdf0e10cSrcweir else
1691cdf0e10cSrcweir {
1692cdf0e10cSrcweir String sMetric = EE_RESSTR(GetMetricId( eDestUnit ));
1693*ae2dc0faSTsutomu Uchino sMetric.Insert( sal_Unicode(' '), 0 );
1694cdf0e10cSrcweir aStr += GetMetricText( (long)nInWidth, eSrcUnit, eDestUnit, pIntl );
1695cdf0e10cSrcweir if ( bMetricStr )
1696cdf0e10cSrcweir aStr += sMetric;
1697cdf0e10cSrcweir aStr += cpDelim;
1698cdf0e10cSrcweir aStr += GetMetricText( (long)nOutWidth, eSrcUnit, eDestUnit, pIntl );
1699cdf0e10cSrcweir if ( bMetricStr )
1700cdf0e10cSrcweir aStr += sMetric;
1701cdf0e10cSrcweir aStr += cpDelim;
1702cdf0e10cSrcweir aStr += GetMetricText( (long)nDistance, eSrcUnit, eDestUnit, pIntl );
1703cdf0e10cSrcweir if ( bMetricStr )
1704cdf0e10cSrcweir aStr += sMetric;
1705cdf0e10cSrcweir }
1706cdf0e10cSrcweir aStr += sal_Unicode(')');
1707cdf0e10cSrcweir return aStr;
1708cdf0e10cSrcweir #else
1709cdf0e10cSrcweir return UniString();
1710cdf0e10cSrcweir #endif
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir
HasPriority(const SvxBorderLine & rOtherLine) const1713cdf0e10cSrcweir bool SvxBorderLine::HasPriority( const SvxBorderLine& rOtherLine ) const
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir const sal_uInt16 nThisSize = GetOutWidth() + GetDistance() + GetInWidth();
1716cdf0e10cSrcweir const sal_uInt16 nOtherSize = rOtherLine.GetOutWidth() + rOtherLine.GetDistance() + rOtherLine.GetInWidth();
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir if (nThisSize > nOtherSize)
1719cdf0e10cSrcweir {
1720cdf0e10cSrcweir return true;
1721cdf0e10cSrcweir }
1722cdf0e10cSrcweir else if (nThisSize < nOtherSize)
1723cdf0e10cSrcweir {
1724cdf0e10cSrcweir return false;
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir else
1727cdf0e10cSrcweir {
1728cdf0e10cSrcweir if ( rOtherLine.GetInWidth() && !GetInWidth() )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir return true;
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir else if ( GetInWidth() && !rOtherLine.GetInWidth() )
1733cdf0e10cSrcweir {
1734cdf0e10cSrcweir return false;
1735cdf0e10cSrcweir }
1736cdf0e10cSrcweir else
1737cdf0e10cSrcweir {
1738cdf0e10cSrcweir return false;
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir }
1741cdf0e10cSrcweir }
1742cdf0e10cSrcweir
1743cdf0e10cSrcweir // class SvxBoxItem ------------------------------------------------------
1744cdf0e10cSrcweir
SvxBoxItem(const SvxBoxItem & rCpy)1745cdf0e10cSrcweir SvxBoxItem::SvxBoxItem( const SvxBoxItem& rCpy ) :
1746cdf0e10cSrcweir
1747cdf0e10cSrcweir SfxPoolItem ( rCpy ),
1748cdf0e10cSrcweir nTopDist ( rCpy.nTopDist ),
1749cdf0e10cSrcweir nBottomDist ( rCpy.nBottomDist ),
1750cdf0e10cSrcweir nLeftDist ( rCpy.nLeftDist ),
1751cdf0e10cSrcweir nRightDist ( rCpy.nRightDist )
1752cdf0e10cSrcweir
1753cdf0e10cSrcweir {
1754cdf0e10cSrcweir pTop = rCpy.GetTop() ? new SvxBorderLine( *rCpy.GetTop() ) : 0;
1755cdf0e10cSrcweir pBottom = rCpy.GetBottom() ? new SvxBorderLine( *rCpy.GetBottom() ) : 0;
1756cdf0e10cSrcweir pLeft = rCpy.GetLeft() ? new SvxBorderLine( *rCpy.GetLeft() ) : 0;
1757cdf0e10cSrcweir pRight = rCpy.GetRight() ? new SvxBorderLine( *rCpy.GetRight() ) : 0;
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir
1760cdf0e10cSrcweir // -----------------------------------------------------------------------
1761cdf0e10cSrcweir
SvxBoxItem(const sal_uInt16 nId)1762cdf0e10cSrcweir SvxBoxItem::SvxBoxItem( const sal_uInt16 nId ) :
1763cdf0e10cSrcweir SfxPoolItem( nId ),
1764cdf0e10cSrcweir
1765cdf0e10cSrcweir pTop ( 0 ),
1766cdf0e10cSrcweir pBottom ( 0 ),
1767cdf0e10cSrcweir pLeft ( 0 ),
1768cdf0e10cSrcweir pRight ( 0 ),
1769cdf0e10cSrcweir nTopDist ( 0 ),
1770cdf0e10cSrcweir nBottomDist ( 0 ),
1771cdf0e10cSrcweir nLeftDist ( 0 ),
1772cdf0e10cSrcweir nRightDist ( 0 )
1773cdf0e10cSrcweir
1774cdf0e10cSrcweir {
1775cdf0e10cSrcweir }
1776cdf0e10cSrcweir
1777cdf0e10cSrcweir // -----------------------------------------------------------------------
1778cdf0e10cSrcweir
~SvxBoxItem()1779cdf0e10cSrcweir SvxBoxItem::~SvxBoxItem()
1780cdf0e10cSrcweir {
1781cdf0e10cSrcweir delete pTop;
1782cdf0e10cSrcweir delete pBottom;
1783cdf0e10cSrcweir delete pLeft;
1784cdf0e10cSrcweir delete pRight;
1785cdf0e10cSrcweir }
1786cdf0e10cSrcweir
1787cdf0e10cSrcweir // -----------------------------------------------------------------------
1788cdf0e10cSrcweir
operator =(const SvxBoxItem & rBox)1789cdf0e10cSrcweir SvxBoxItem& SvxBoxItem::operator=( const SvxBoxItem& rBox )
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir nTopDist = rBox.nTopDist;
1792cdf0e10cSrcweir nBottomDist = rBox.nBottomDist;
1793cdf0e10cSrcweir nLeftDist = rBox.nLeftDist;
1794cdf0e10cSrcweir nRightDist = rBox.nRightDist;
1795cdf0e10cSrcweir SetLine( rBox.GetTop(), BOX_LINE_TOP );
1796cdf0e10cSrcweir SetLine( rBox.GetBottom(), BOX_LINE_BOTTOM );
1797cdf0e10cSrcweir SetLine( rBox.GetLeft(), BOX_LINE_LEFT );
1798cdf0e10cSrcweir SetLine( rBox.GetRight(), BOX_LINE_RIGHT );
1799cdf0e10cSrcweir return *this;
1800cdf0e10cSrcweir }
1801cdf0e10cSrcweir
1802cdf0e10cSrcweir // -----------------------------------------------------------------------
1803cdf0e10cSrcweir
CmpBrdLn(const SvxBorderLine * pBrd1,const SvxBorderLine * pBrd2)1804cdf0e10cSrcweir inline sal_Bool CmpBrdLn( const SvxBorderLine* pBrd1, const SvxBorderLine* pBrd2 )
1805cdf0e10cSrcweir {
1806cdf0e10cSrcweir sal_Bool bRet;
1807cdf0e10cSrcweir if( 0 != pBrd1 ? 0 == pBrd2 : 0 != pBrd2 )
1808cdf0e10cSrcweir bRet = sal_False;
1809cdf0e10cSrcweir else
1810cdf0e10cSrcweir if( !pBrd1 )
1811cdf0e10cSrcweir bRet = sal_True;
1812cdf0e10cSrcweir else
1813cdf0e10cSrcweir bRet = (*pBrd1 == *pBrd2);
1814cdf0e10cSrcweir return bRet;
1815cdf0e10cSrcweir }
1816cdf0e10cSrcweir
1817cdf0e10cSrcweir // -----------------------------------------------------------------------
1818cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const1819cdf0e10cSrcweir int SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
1820cdf0e10cSrcweir {
1821cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
1822cdf0e10cSrcweir
1823cdf0e10cSrcweir return (
1824cdf0e10cSrcweir ( nTopDist == ( (SvxBoxItem&)rAttr ).nTopDist ) &&
1825cdf0e10cSrcweir ( nBottomDist == ( (SvxBoxItem&)rAttr ).nBottomDist ) &&
1826cdf0e10cSrcweir ( nLeftDist == ( (SvxBoxItem&)rAttr ).nLeftDist ) &&
1827cdf0e10cSrcweir ( nRightDist == ( (SvxBoxItem&)rAttr ).nRightDist ) &&
1828cdf0e10cSrcweir CmpBrdLn( pTop, ( (SvxBoxItem&)rAttr ).GetTop() ) &&
1829cdf0e10cSrcweir CmpBrdLn( pBottom, ( (SvxBoxItem&)rAttr ).GetBottom() ) &&
1830cdf0e10cSrcweir CmpBrdLn( pLeft, ( (SvxBoxItem&)rAttr ).GetLeft() ) &&
1831cdf0e10cSrcweir CmpBrdLn( pRight, ( (SvxBoxItem&)rAttr ).GetRight() ) );
1832cdf0e10cSrcweir }
1833cdf0e10cSrcweir
1834cdf0e10cSrcweir // -----------------------------------------------------------------------
SvxLineToLine(const SvxBorderLine * pLine,sal_Bool bConvert)1835cdf0e10cSrcweir table::BorderLine SvxBoxItem::SvxLineToLine(const SvxBorderLine* pLine, sal_Bool bConvert)
1836cdf0e10cSrcweir {
1837cdf0e10cSrcweir table::BorderLine aLine;
1838cdf0e10cSrcweir if(pLine)
1839cdf0e10cSrcweir {
1840cdf0e10cSrcweir aLine.Color = pLine->GetColor().GetColor() ;
1841cdf0e10cSrcweir aLine.InnerLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetInWidth() ): pLine->GetInWidth() );
1842cdf0e10cSrcweir aLine.OuterLineWidth = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetOutWidth()): pLine->GetOutWidth() );
1843cdf0e10cSrcweir aLine.LineDistance = sal_uInt16( bConvert ? TWIP_TO_MM100_UNSIGNED(pLine->GetDistance()): pLine->GetDistance() );
1844cdf0e10cSrcweir }
1845cdf0e10cSrcweir else
1846cdf0e10cSrcweir aLine.Color = aLine.InnerLineWidth = aLine.OuterLineWidth = aLine.LineDistance = 0;
1847cdf0e10cSrcweir return aLine;
1848cdf0e10cSrcweir }
1849cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const1850cdf0e10cSrcweir sal_Bool SvxBoxItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
1851cdf0e10cSrcweir {
1852cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1853cdf0e10cSrcweir table::BorderLine aRetLine;
1854cdf0e10cSrcweir sal_uInt16 nDist = 0;
1855cdf0e10cSrcweir sal_Bool bDistMember = sal_False;
1856cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1857cdf0e10cSrcweir sal_Bool bSerialize = sal_False;
1858cdf0e10cSrcweir switch(nMemberId)
1859cdf0e10cSrcweir {
1860cdf0e10cSrcweir case 0:
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir // 4 Borders and 5 distances
1863cdf0e10cSrcweir uno::Sequence< uno::Any > aSeq( 9 );
1864cdf0e10cSrcweir aSeq[0] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetLeft(), bConvert) );
1865cdf0e10cSrcweir aSeq[1] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetRight(), bConvert) );
1866cdf0e10cSrcweir aSeq[2] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetBottom(), bConvert) );
1867cdf0e10cSrcweir aSeq[3] = uno::makeAny( SvxBoxItem::SvxLineToLine(GetTop(), bConvert) );
1868cdf0e10cSrcweir aSeq[4] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( GetDistance()) : GetDistance()));
1869cdf0e10cSrcweir aSeq[5] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nTopDist ) : nTopDist ));
1870cdf0e10cSrcweir aSeq[6] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nBottomDist ) : nBottomDist ));
1871cdf0e10cSrcweir aSeq[7] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nLeftDist ) : nLeftDist ));
1872cdf0e10cSrcweir aSeq[8] <<= uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED( nRightDist ) : nRightDist ));
1873cdf0e10cSrcweir rVal = uno::makeAny( aSeq );
1874cdf0e10cSrcweir return sal_True;
1875cdf0e10cSrcweir }
1876cdf0e10cSrcweir case MID_LEFT_BORDER:
1877cdf0e10cSrcweir bSerialize = sal_True; // intentionally no break!
1878cdf0e10cSrcweir case LEFT_BORDER:
1879cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine(GetLeft(), bConvert);
1880cdf0e10cSrcweir break;
1881cdf0e10cSrcweir case MID_RIGHT_BORDER:
1882cdf0e10cSrcweir bSerialize = sal_True; // intentionally no break!
1883cdf0e10cSrcweir case RIGHT_BORDER:
1884cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine(GetRight(), bConvert);
1885cdf0e10cSrcweir break;
1886cdf0e10cSrcweir case MID_BOTTOM_BORDER:
1887cdf0e10cSrcweir bSerialize = sal_True; // intentionally no break!
1888cdf0e10cSrcweir case BOTTOM_BORDER:
1889cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine(GetBottom(), bConvert);
1890cdf0e10cSrcweir break;
1891cdf0e10cSrcweir case MID_TOP_BORDER:
1892cdf0e10cSrcweir bSerialize = sal_True; // intentionally no break!
1893cdf0e10cSrcweir case TOP_BORDER:
1894cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine(GetTop(), bConvert);
1895cdf0e10cSrcweir break;
1896cdf0e10cSrcweir case BORDER_DISTANCE:
1897cdf0e10cSrcweir nDist = GetDistance();
1898cdf0e10cSrcweir bDistMember = sal_True;
1899cdf0e10cSrcweir break;
1900cdf0e10cSrcweir case TOP_BORDER_DISTANCE:
1901cdf0e10cSrcweir nDist = nTopDist;
1902cdf0e10cSrcweir bDistMember = sal_True;
1903cdf0e10cSrcweir break;
1904cdf0e10cSrcweir case BOTTOM_BORDER_DISTANCE:
1905cdf0e10cSrcweir nDist = nBottomDist;
1906cdf0e10cSrcweir bDistMember = sal_True;
1907cdf0e10cSrcweir break;
1908cdf0e10cSrcweir case LEFT_BORDER_DISTANCE:
1909cdf0e10cSrcweir nDist = nLeftDist;
1910cdf0e10cSrcweir bDistMember = sal_True;
1911cdf0e10cSrcweir break;
1912cdf0e10cSrcweir case RIGHT_BORDER_DISTANCE:
1913cdf0e10cSrcweir nDist = nRightDist;
1914cdf0e10cSrcweir bDistMember = sal_True;
1915cdf0e10cSrcweir break;
1916cdf0e10cSrcweir }
1917cdf0e10cSrcweir
1918cdf0e10cSrcweir if( bDistMember )
1919cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(nDist) : nDist);
1920cdf0e10cSrcweir else
1921cdf0e10cSrcweir {
1922cdf0e10cSrcweir /*
1923cdf0e10cSrcweir if ( bSerialize )
1924cdf0e10cSrcweir {
1925cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
1926cdf0e10cSrcweir aSeq[0] <<= aRetLine.Color;
1927cdf0e10cSrcweir aSeq[1] <<= aRetLine.InnerLineWidth;
1928cdf0e10cSrcweir aSeq[2] <<= aRetLine.OuterLineWidth;
1929cdf0e10cSrcweir aSeq[3] <<= aRetLine.LineDistance;
1930cdf0e10cSrcweir rVal <<= aSeq;
1931cdf0e10cSrcweir }
1932cdf0e10cSrcweir else
1933cdf0e10cSrcweir */
1934cdf0e10cSrcweir rVal <<= aRetLine;
1935cdf0e10cSrcweir }
1936cdf0e10cSrcweir
1937cdf0e10cSrcweir return sal_True;
1938cdf0e10cSrcweir }
1939cdf0e10cSrcweir
1940cdf0e10cSrcweir // -----------------------------------------------------------------------
LineToSvxLine(const::com::sun::star::table::BorderLine & rLine,SvxBorderLine & rSvxLine,sal_Bool bConvert)1941cdf0e10cSrcweir sal_Bool SvxBoxItem::LineToSvxLine(const ::com::sun::star::table::BorderLine& rLine, SvxBorderLine& rSvxLine, sal_Bool bConvert)
1942cdf0e10cSrcweir {
1943cdf0e10cSrcweir rSvxLine.SetColor( Color(rLine.Color));
1944cdf0e10cSrcweir rSvxLine.SetInWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.InnerLineWidth) : rLine.InnerLineWidth ));
1945cdf0e10cSrcweir rSvxLine.SetOutWidth( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.OuterLineWidth) : rLine.OuterLineWidth ));
1946cdf0e10cSrcweir rSvxLine.SetDistance( sal_uInt16( bConvert ? MM100_TO_TWIP(rLine.LineDistance ) : rLine.LineDistance ));
1947cdf0e10cSrcweir sal_Bool bRet = rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
1948cdf0e10cSrcweir return bRet;
1949cdf0e10cSrcweir }
1950cdf0e10cSrcweir
1951cdf0e10cSrcweir // -----------------------------------------------------------------------
1952cdf0e10cSrcweir
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)1953cdf0e10cSrcweir sal_Bool SvxBoxItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
1954cdf0e10cSrcweir {
1955cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
1956cdf0e10cSrcweir sal_uInt16 nLine = BOX_LINE_TOP;
1957cdf0e10cSrcweir sal_Bool bDistMember = sal_False;
1958cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
1959cdf0e10cSrcweir switch(nMemberId)
1960cdf0e10cSrcweir {
1961cdf0e10cSrcweir case 0:
1962cdf0e10cSrcweir {
1963cdf0e10cSrcweir uno::Sequence< uno::Any > aSeq;
1964cdf0e10cSrcweir if (( rVal >>= aSeq ) && ( aSeq.getLength() == 9 ))
1965cdf0e10cSrcweir {
1966cdf0e10cSrcweir // 4 Borders and 5 distances
1967cdf0e10cSrcweir sal_Int32 nDist = 0;
1968cdf0e10cSrcweir SvxBorderLine aLine;
1969cdf0e10cSrcweir table::BorderLine aBorderLine;
1970cdf0e10cSrcweir if ( aSeq[0] >>= aBorderLine )
1971cdf0e10cSrcweir {
1972cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1973cdf0e10cSrcweir SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT );
1974cdf0e10cSrcweir }
1975cdf0e10cSrcweir else
1976cdf0e10cSrcweir return sal_False;
1977cdf0e10cSrcweir
1978cdf0e10cSrcweir if ( aSeq[1] >>= aBorderLine )
1979cdf0e10cSrcweir {
1980cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1981cdf0e10cSrcweir SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT );
1982cdf0e10cSrcweir }
1983cdf0e10cSrcweir else
1984cdf0e10cSrcweir return sal_False;
1985cdf0e10cSrcweir
1986cdf0e10cSrcweir if ( aSeq[2] >>= aBorderLine )
1987cdf0e10cSrcweir {
1988cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1989cdf0e10cSrcweir SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM );
1990cdf0e10cSrcweir }
1991cdf0e10cSrcweir else
1992cdf0e10cSrcweir return sal_False;
1993cdf0e10cSrcweir
1994cdf0e10cSrcweir if ( aSeq[3] >>= aBorderLine )
1995cdf0e10cSrcweir {
1996cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
1997cdf0e10cSrcweir SetLine(bSet ? &aLine : 0, BOX_LINE_TOP );
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir else
2000cdf0e10cSrcweir return sal_False;
2001cdf0e10cSrcweir
2002cdf0e10cSrcweir sal_uInt16 nLines[4] = { BOX_LINE_TOP, BOX_LINE_BOTTOM, BOX_LINE_LEFT, BOX_LINE_RIGHT };
2003cdf0e10cSrcweir for ( sal_Int32 n = 4; n < 9; n++ )
2004cdf0e10cSrcweir {
2005cdf0e10cSrcweir if ( aSeq[n] >>= nDist )
2006cdf0e10cSrcweir {
2007cdf0e10cSrcweir if( bConvert )
2008cdf0e10cSrcweir nDist = MM100_TO_TWIP(nDist);
2009cdf0e10cSrcweir if ( n == 4 )
2010cdf0e10cSrcweir SetDistance( sal_uInt16( nDist ));
2011cdf0e10cSrcweir else
2012cdf0e10cSrcweir SetDistance( sal_uInt16( nDist ), nLines[n-5] );
2013cdf0e10cSrcweir }
2014cdf0e10cSrcweir else
2015cdf0e10cSrcweir return sal_False;
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir
2018cdf0e10cSrcweir return sal_True;
2019cdf0e10cSrcweir }
2020cdf0e10cSrcweir else
2021cdf0e10cSrcweir return sal_False;
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir case LEFT_BORDER_DISTANCE:
2024cdf0e10cSrcweir bDistMember = sal_True;
2025cdf0e10cSrcweir case LEFT_BORDER:
2026cdf0e10cSrcweir case MID_LEFT_BORDER:
2027cdf0e10cSrcweir nLine = BOX_LINE_LEFT;
2028cdf0e10cSrcweir break;
2029cdf0e10cSrcweir case RIGHT_BORDER_DISTANCE:
2030cdf0e10cSrcweir bDistMember = sal_True;
2031cdf0e10cSrcweir case RIGHT_BORDER:
2032cdf0e10cSrcweir case MID_RIGHT_BORDER:
2033cdf0e10cSrcweir nLine = BOX_LINE_RIGHT;
2034cdf0e10cSrcweir break;
2035cdf0e10cSrcweir case BOTTOM_BORDER_DISTANCE:
2036cdf0e10cSrcweir bDistMember = sal_True;
2037cdf0e10cSrcweir case BOTTOM_BORDER:
2038cdf0e10cSrcweir case MID_BOTTOM_BORDER:
2039cdf0e10cSrcweir nLine = BOX_LINE_BOTTOM;
2040cdf0e10cSrcweir break;
2041cdf0e10cSrcweir case TOP_BORDER_DISTANCE:
2042cdf0e10cSrcweir bDistMember = sal_True;
2043cdf0e10cSrcweir case TOP_BORDER:
2044cdf0e10cSrcweir case MID_TOP_BORDER:
2045cdf0e10cSrcweir nLine = BOX_LINE_TOP;
2046cdf0e10cSrcweir break;
2047cdf0e10cSrcweir }
2048cdf0e10cSrcweir
2049cdf0e10cSrcweir if( bDistMember || nMemberId == BORDER_DISTANCE )
2050cdf0e10cSrcweir {
2051cdf0e10cSrcweir sal_Int32 nDist = 0;
2052cdf0e10cSrcweir if(!(rVal >>= nDist))
2053cdf0e10cSrcweir return sal_False;
2054cdf0e10cSrcweir
2055cdf0e10cSrcweir if(nDist >= 0)
2056cdf0e10cSrcweir {
2057cdf0e10cSrcweir if( bConvert )
2058cdf0e10cSrcweir nDist = MM100_TO_TWIP(nDist);
2059cdf0e10cSrcweir if( nMemberId == BORDER_DISTANCE )
2060cdf0e10cSrcweir SetDistance( sal_uInt16( nDist ));
2061cdf0e10cSrcweir else
2062cdf0e10cSrcweir SetDistance( sal_uInt16( nDist ), nLine );
2063cdf0e10cSrcweir }
2064cdf0e10cSrcweir }
2065cdf0e10cSrcweir else
2066cdf0e10cSrcweir {
2067cdf0e10cSrcweir SvxBorderLine aLine;
2068cdf0e10cSrcweir if( !rVal.hasValue() )
2069cdf0e10cSrcweir return sal_False;
2070cdf0e10cSrcweir
2071cdf0e10cSrcweir table::BorderLine aBorderLine;
2072cdf0e10cSrcweir if( rVal >>= aBorderLine )
2073cdf0e10cSrcweir {
2074cdf0e10cSrcweir // usual struct
2075cdf0e10cSrcweir }
2076cdf0e10cSrcweir else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2077cdf0e10cSrcweir {
2078cdf0e10cSrcweir // serialization for basic macro recording
2079cdf0e10cSrcweir uno::Reference < script::XTypeConverter > xConverter
2080cdf0e10cSrcweir ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2081cdf0e10cSrcweir uno::UNO_QUERY );
2082cdf0e10cSrcweir uno::Sequence < uno::Any > aSeq;
2083cdf0e10cSrcweir uno::Any aNew;
2084cdf0e10cSrcweir try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
2085cdf0e10cSrcweir catch (uno::Exception&) {}
2086cdf0e10cSrcweir
2087cdf0e10cSrcweir aNew >>= aSeq;
2088cdf0e10cSrcweir if ( aSeq.getLength() == 4 )
2089cdf0e10cSrcweir {
2090cdf0e10cSrcweir sal_Int32 nVal = 0;
2091cdf0e10cSrcweir if ( aSeq[0] >>= nVal )
2092cdf0e10cSrcweir aBorderLine.Color = nVal;
2093cdf0e10cSrcweir if ( aSeq[1] >>= nVal )
2094cdf0e10cSrcweir aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2095cdf0e10cSrcweir if ( aSeq[2] >>= nVal )
2096cdf0e10cSrcweir aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2097cdf0e10cSrcweir if ( aSeq[3] >>= nVal )
2098cdf0e10cSrcweir aBorderLine.LineDistance = (sal_Int16) nVal;
2099cdf0e10cSrcweir }
2100cdf0e10cSrcweir else
2101cdf0e10cSrcweir return sal_False;
2102cdf0e10cSrcweir }
2103cdf0e10cSrcweir else
2104cdf0e10cSrcweir return sal_False;
2105cdf0e10cSrcweir
2106cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2107cdf0e10cSrcweir SetLine(bSet ? &aLine : 0, nLine);
2108cdf0e10cSrcweir }
2109cdf0e10cSrcweir
2110cdf0e10cSrcweir return sal_True;
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir
2113cdf0e10cSrcweir // -----------------------------------------------------------------------
2114cdf0e10cSrcweir
Clone(SfxItemPool *) const2115cdf0e10cSrcweir SfxPoolItem* SvxBoxItem::Clone( SfxItemPool* ) const
2116cdf0e10cSrcweir {
2117cdf0e10cSrcweir return new SvxBoxItem( *this );
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir
2120cdf0e10cSrcweir //------------------------------------------------------------------------
2121cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const2122cdf0e10cSrcweir SfxItemPresentation SvxBoxItem::GetPresentation
2123cdf0e10cSrcweir (
2124cdf0e10cSrcweir SfxItemPresentation ePres,
2125cdf0e10cSrcweir SfxMapUnit eCoreUnit,
2126cdf0e10cSrcweir SfxMapUnit ePresUnit,
2127cdf0e10cSrcweir XubString& rText, const IntlWrapper *pIntl
2128cdf0e10cSrcweir ) const
2129cdf0e10cSrcweir {
2130cdf0e10cSrcweir #ifndef SVX_LIGHT
2131cdf0e10cSrcweir switch ( ePres )
2132cdf0e10cSrcweir {
2133cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
2134cdf0e10cSrcweir rText.Erase();
2135cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
2136cdf0e10cSrcweir
2137cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
2138cdf0e10cSrcweir {
2139cdf0e10cSrcweir rText.Erase();
2140cdf0e10cSrcweir
2141cdf0e10cSrcweir if ( pTop )
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir rText = pTop->GetValueString( eCoreUnit, ePresUnit, pIntl );
2144cdf0e10cSrcweir rText += cpDelim;
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir if( !(pTop && pBottom && pLeft && pRight &&
2147cdf0e10cSrcweir *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight) )
2148cdf0e10cSrcweir {
2149cdf0e10cSrcweir if ( pBottom )
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl );
2152cdf0e10cSrcweir rText += cpDelim;
2153cdf0e10cSrcweir }
2154cdf0e10cSrcweir if ( pLeft )
2155cdf0e10cSrcweir {
2156cdf0e10cSrcweir rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl );
2157cdf0e10cSrcweir rText += cpDelim;
2158cdf0e10cSrcweir }
2159cdf0e10cSrcweir if ( pRight )
2160cdf0e10cSrcweir {
2161cdf0e10cSrcweir rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl );
2162cdf0e10cSrcweir rText += cpDelim;
2163cdf0e10cSrcweir }
2164cdf0e10cSrcweir }
2165cdf0e10cSrcweir rText += GetMetricText( (long)nTopDist, eCoreUnit, ePresUnit, pIntl );
2166cdf0e10cSrcweir if( nTopDist != nBottomDist || nTopDist != nLeftDist ||
2167cdf0e10cSrcweir nTopDist != nRightDist )
2168cdf0e10cSrcweir {
2169cdf0e10cSrcweir (((((rText += cpDelim)
2170cdf0e10cSrcweir += GetMetricText( (long)nBottomDist, eCoreUnit,
2171cdf0e10cSrcweir ePresUnit, pIntl ))
2172cdf0e10cSrcweir += cpDelim)
2173cdf0e10cSrcweir += GetMetricText( (long)nLeftDist, eCoreUnit, ePresUnit, pIntl ))
2174cdf0e10cSrcweir += cpDelim)
2175cdf0e10cSrcweir += GetMetricText( (long)nRightDist, eCoreUnit,
2176cdf0e10cSrcweir ePresUnit, pIntl );
2177cdf0e10cSrcweir }
2178cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
2179cdf0e10cSrcweir }
2180cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir if( !(pTop || pBottom || pLeft || pRight) )
2183cdf0e10cSrcweir {
2184cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_BORDER_NONE);
2185cdf0e10cSrcweir rText += cpDelim;
2186cdf0e10cSrcweir }
2187cdf0e10cSrcweir else
2188cdf0e10cSrcweir {
2189cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_BORDER_COMPLETE);
2190cdf0e10cSrcweir if( pTop && pBottom && pLeft && pRight &&
2191cdf0e10cSrcweir *pTop == *pBottom && *pTop == *pLeft && *pTop == *pRight )
2192cdf0e10cSrcweir {
2193cdf0e10cSrcweir rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2194cdf0e10cSrcweir rText += cpDelim;
2195cdf0e10cSrcweir }
2196cdf0e10cSrcweir else
2197cdf0e10cSrcweir {
2198cdf0e10cSrcweir if ( pTop )
2199cdf0e10cSrcweir {
2200cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP);
2201cdf0e10cSrcweir rText += pTop->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2202cdf0e10cSrcweir rText += cpDelim;
2203cdf0e10cSrcweir }
2204cdf0e10cSrcweir if ( pBottom )
2205cdf0e10cSrcweir {
2206cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM);
2207cdf0e10cSrcweir rText += pBottom->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2208cdf0e10cSrcweir rText += cpDelim;
2209cdf0e10cSrcweir }
2210cdf0e10cSrcweir if ( pLeft )
2211cdf0e10cSrcweir {
2212cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT);
2213cdf0e10cSrcweir rText += pLeft->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2214cdf0e10cSrcweir rText += cpDelim;
2215cdf0e10cSrcweir }
2216cdf0e10cSrcweir if ( pRight )
2217cdf0e10cSrcweir {
2218cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT);
2219cdf0e10cSrcweir rText += pRight->GetValueString( eCoreUnit, ePresUnit, pIntl, sal_True );
2220cdf0e10cSrcweir rText += cpDelim;
2221cdf0e10cSrcweir }
2222cdf0e10cSrcweir }
2223cdf0e10cSrcweir }
2224cdf0e10cSrcweir
2225cdf0e10cSrcweir rText += EE_RESSTR(RID_SVXITEMS_BORDER_DISTANCE);
2226cdf0e10cSrcweir if( nTopDist == nBottomDist && nTopDist == nLeftDist &&
2227cdf0e10cSrcweir nTopDist == nRightDist )
2228cdf0e10cSrcweir {
2229cdf0e10cSrcweir rText += GetMetricText( (long)nTopDist, eCoreUnit,
2230cdf0e10cSrcweir ePresUnit, pIntl );
2231*ae2dc0faSTsutomu Uchino rText += sal_Unicode(' ');
2232cdf0e10cSrcweir rText += EE_RESSTR(GetMetricId(ePresUnit));
2233cdf0e10cSrcweir }
2234cdf0e10cSrcweir else
2235cdf0e10cSrcweir {
2236*ae2dc0faSTsutomu Uchino ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_TOP))
2237cdf0e10cSrcweir += GetMetricText( (long)nTopDist, eCoreUnit,
2238cdf0e10cSrcweir ePresUnit, pIntl ))
2239*ae2dc0faSTsutomu Uchino += sal_Unicode(' '))
2240cdf0e10cSrcweir += EE_RESSTR(GetMetricId(ePresUnit)))
2241cdf0e10cSrcweir += cpDelim;
2242*ae2dc0faSTsutomu Uchino ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_BOTTOM))
2243cdf0e10cSrcweir += GetMetricText( (long)nBottomDist, eCoreUnit,
2244cdf0e10cSrcweir ePresUnit, pIntl ))
2245*ae2dc0faSTsutomu Uchino += sal_Unicode(' '))
2246cdf0e10cSrcweir += EE_RESSTR(GetMetricId(ePresUnit)))
2247cdf0e10cSrcweir += cpDelim;
2248*ae2dc0faSTsutomu Uchino ((((rText += EE_RESSTR(RID_SVXITEMS_BORDER_LEFT))
2249cdf0e10cSrcweir += GetMetricText( (long)nLeftDist, eCoreUnit,
2250cdf0e10cSrcweir ePresUnit, pIntl ))
2251*ae2dc0faSTsutomu Uchino += sal_Unicode(' '))
2252cdf0e10cSrcweir += EE_RESSTR(GetMetricId(ePresUnit)))
2253cdf0e10cSrcweir += cpDelim;
2254*ae2dc0faSTsutomu Uchino (((rText += EE_RESSTR(RID_SVXITEMS_BORDER_RIGHT))
2255cdf0e10cSrcweir += GetMetricText( (long)nRightDist, eCoreUnit,
2256cdf0e10cSrcweir ePresUnit, pIntl ))
2257*ae2dc0faSTsutomu Uchino += sal_Unicode(' '))
2258cdf0e10cSrcweir += EE_RESSTR(GetMetricId(ePresUnit));
2259cdf0e10cSrcweir }
2260cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE;
2261cdf0e10cSrcweir }
2262cdf0e10cSrcweir default: ;//prevent warning
2263cdf0e10cSrcweir }
2264cdf0e10cSrcweir #endif // !SVX_LIGHT
2265cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
2266cdf0e10cSrcweir }
2267cdf0e10cSrcweir
2268cdf0e10cSrcweir // -----------------------------------------------------------------------
2269cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const2270cdf0e10cSrcweir SvStream& SvxBoxItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
2271cdf0e10cSrcweir {
2272cdf0e10cSrcweir rStrm << (sal_uInt16) GetDistance();
2273cdf0e10cSrcweir const SvxBorderLine* pLine[ 4 ]; // top, left, right, bottom
2274cdf0e10cSrcweir pLine[ 0 ] = GetTop();
2275cdf0e10cSrcweir pLine[ 1 ] = GetLeft();
2276cdf0e10cSrcweir pLine[ 2 ] = GetRight();
2277cdf0e10cSrcweir pLine[ 3 ] = GetBottom();
2278cdf0e10cSrcweir
2279cdf0e10cSrcweir for( int i = 0; i < 4; i++ )
2280cdf0e10cSrcweir {
2281cdf0e10cSrcweir const SvxBorderLine* l = pLine[ i ];
2282cdf0e10cSrcweir if( l )
2283cdf0e10cSrcweir {
2284cdf0e10cSrcweir rStrm << (sal_Int8) i
2285cdf0e10cSrcweir << l->GetColor()
2286cdf0e10cSrcweir << (sal_uInt16) l->GetOutWidth()
2287cdf0e10cSrcweir << (sal_uInt16) l->GetInWidth()
2288cdf0e10cSrcweir << (sal_uInt16) l->GetDistance();
2289cdf0e10cSrcweir }
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir sal_Int8 cLine = 4;
2292cdf0e10cSrcweir if( nItemVersion >= BOX_4DISTS_VERSION &&
2293cdf0e10cSrcweir !(nTopDist == nLeftDist &&
2294cdf0e10cSrcweir nTopDist == nRightDist &&
2295cdf0e10cSrcweir nTopDist == nBottomDist) )
2296cdf0e10cSrcweir {
2297cdf0e10cSrcweir cLine |= 0x10;
2298cdf0e10cSrcweir }
2299cdf0e10cSrcweir
2300cdf0e10cSrcweir rStrm << cLine;
2301cdf0e10cSrcweir
2302cdf0e10cSrcweir if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
2303cdf0e10cSrcweir {
2304cdf0e10cSrcweir rStrm << (sal_uInt16)nTopDist
2305cdf0e10cSrcweir << (sal_uInt16)nLeftDist
2306cdf0e10cSrcweir << (sal_uInt16)nRightDist
2307cdf0e10cSrcweir << (sal_uInt16)nBottomDist;
2308cdf0e10cSrcweir }
2309cdf0e10cSrcweir
2310cdf0e10cSrcweir return rStrm;
2311cdf0e10cSrcweir }
2312cdf0e10cSrcweir
2313cdf0e10cSrcweir // -----------------------------------------------------------------------
2314cdf0e10cSrcweir
GetVersion(sal_uInt16 nFFVer) const2315cdf0e10cSrcweir sal_uInt16 SvxBoxItem::GetVersion( sal_uInt16 nFFVer ) const
2316cdf0e10cSrcweir {
2317cdf0e10cSrcweir DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
2318cdf0e10cSrcweir SOFFICE_FILEFORMAT_40==nFFVer ||
2319cdf0e10cSrcweir SOFFICE_FILEFORMAT_50==nFFVer,
2320cdf0e10cSrcweir "SvxBoxItem: Gibt es ein neues Fileformat?" );
2321cdf0e10cSrcweir return SOFFICE_FILEFORMAT_31==nFFVer ||
2322cdf0e10cSrcweir SOFFICE_FILEFORMAT_40==nFFVer ? 0 : BOX_4DISTS_VERSION;
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir
2325cdf0e10cSrcweir // -----------------------------------------------------------------------
2326cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)2327cdf0e10cSrcweir int SvxBoxItem::ScaleMetrics( long nMult, long nDiv )
2328cdf0e10cSrcweir {
2329cdf0e10cSrcweir if ( pTop ) pTop->ScaleMetrics( nMult, nDiv );
2330cdf0e10cSrcweir if ( pBottom ) pBottom->ScaleMetrics( nMult, nDiv );
2331cdf0e10cSrcweir if ( pLeft ) pLeft->ScaleMetrics( nMult, nDiv );
2332cdf0e10cSrcweir if ( pRight ) pBottom->ScaleMetrics( nMult, nDiv );
2333cdf0e10cSrcweir nTopDist = (sal_uInt16)Scale( nTopDist, nMult, nDiv );
2334cdf0e10cSrcweir nBottomDist = (sal_uInt16)Scale( nBottomDist, nMult, nDiv );
2335cdf0e10cSrcweir nLeftDist = (sal_uInt16)Scale( nLeftDist, nMult, nDiv );
2336cdf0e10cSrcweir nRightDist = (sal_uInt16)Scale( nRightDist, nMult, nDiv );
2337cdf0e10cSrcweir return 1;
2338cdf0e10cSrcweir }
2339cdf0e10cSrcweir
2340cdf0e10cSrcweir // -----------------------------------------------------------------------
2341cdf0e10cSrcweir
HasMetrics() const2342cdf0e10cSrcweir int SvxBoxItem::HasMetrics() const
2343cdf0e10cSrcweir {
2344cdf0e10cSrcweir return 1;
2345cdf0e10cSrcweir }
2346cdf0e10cSrcweir
2347cdf0e10cSrcweir // -----------------------------------------------------------------------
2348cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16 nIVersion) const2349cdf0e10cSrcweir SfxPoolItem* SvxBoxItem::Create( SvStream& rStrm, sal_uInt16 nIVersion ) const
2350cdf0e10cSrcweir {
2351cdf0e10cSrcweir sal_uInt16 nDistance;
2352cdf0e10cSrcweir rStrm >> nDistance;
2353cdf0e10cSrcweir SvxBoxItem* pAttr = new SvxBoxItem( Which() );
2354cdf0e10cSrcweir
2355cdf0e10cSrcweir sal_uInt16 aLineMap[4] = { BOX_LINE_TOP, BOX_LINE_LEFT,
2356cdf0e10cSrcweir BOX_LINE_RIGHT, BOX_LINE_BOTTOM };
2357cdf0e10cSrcweir
2358cdf0e10cSrcweir sal_Int8 cLine;
2359cdf0e10cSrcweir while( sal_True )
2360cdf0e10cSrcweir {
2361cdf0e10cSrcweir rStrm >> cLine;
2362cdf0e10cSrcweir
2363cdf0e10cSrcweir if( cLine > 3 )
2364cdf0e10cSrcweir break;
2365cdf0e10cSrcweir sal_uInt16 nOutline, nInline, _nDistance;
2366cdf0e10cSrcweir Color aColor;
2367cdf0e10cSrcweir rStrm >> aColor >> nOutline >> nInline >> _nDistance;
2368cdf0e10cSrcweir SvxBorderLine aBorder( &aColor, nOutline, nInline, _nDistance );
2369cdf0e10cSrcweir
2370cdf0e10cSrcweir pAttr->SetLine( &aBorder, aLineMap[cLine] );
2371cdf0e10cSrcweir }
2372cdf0e10cSrcweir
2373cdf0e10cSrcweir if( nIVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
2374cdf0e10cSrcweir {
2375cdf0e10cSrcweir for( sal_uInt16 i=0; i < 4; i++ )
2376cdf0e10cSrcweir {
2377cdf0e10cSrcweir sal_uInt16 nDist;
2378cdf0e10cSrcweir rStrm >> nDist;
2379cdf0e10cSrcweir pAttr->SetDistance( nDist, aLineMap[i] );
2380cdf0e10cSrcweir }
2381cdf0e10cSrcweir }
2382cdf0e10cSrcweir else
2383cdf0e10cSrcweir {
2384cdf0e10cSrcweir pAttr->SetDistance( nDistance );
2385cdf0e10cSrcweir }
2386cdf0e10cSrcweir
2387cdf0e10cSrcweir return pAttr;
2388cdf0e10cSrcweir }
2389cdf0e10cSrcweir
2390cdf0e10cSrcweir // -----------------------------------------------------------------------
2391cdf0e10cSrcweir
GetLine(sal_uInt16 nLine) const2392cdf0e10cSrcweir const SvxBorderLine *SvxBoxItem::GetLine( sal_uInt16 nLine ) const
2393cdf0e10cSrcweir {
2394cdf0e10cSrcweir const SvxBorderLine *pRet = 0;
2395cdf0e10cSrcweir
2396cdf0e10cSrcweir switch ( nLine )
2397cdf0e10cSrcweir {
2398cdf0e10cSrcweir case BOX_LINE_TOP:
2399cdf0e10cSrcweir pRet = pTop;
2400cdf0e10cSrcweir break;
2401cdf0e10cSrcweir case BOX_LINE_BOTTOM:
2402cdf0e10cSrcweir pRet = pBottom;
2403cdf0e10cSrcweir break;
2404cdf0e10cSrcweir case BOX_LINE_LEFT:
2405cdf0e10cSrcweir pRet = pLeft;
2406cdf0e10cSrcweir break;
2407cdf0e10cSrcweir case BOX_LINE_RIGHT:
2408cdf0e10cSrcweir pRet = pRight;
2409cdf0e10cSrcweir break;
2410cdf0e10cSrcweir default:
2411cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2412cdf0e10cSrcweir break;
2413cdf0e10cSrcweir }
2414cdf0e10cSrcweir
2415cdf0e10cSrcweir return pRet;
2416cdf0e10cSrcweir }
2417cdf0e10cSrcweir
2418cdf0e10cSrcweir // -----------------------------------------------------------------------
2419cdf0e10cSrcweir
SetLine(const SvxBorderLine * pNew,sal_uInt16 nLine)2420cdf0e10cSrcweir void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2421cdf0e10cSrcweir {
2422cdf0e10cSrcweir SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2423cdf0e10cSrcweir
2424cdf0e10cSrcweir switch ( nLine )
2425cdf0e10cSrcweir {
2426cdf0e10cSrcweir case BOX_LINE_TOP:
2427cdf0e10cSrcweir delete pTop;
2428cdf0e10cSrcweir pTop = pTmp;
2429cdf0e10cSrcweir break;
2430cdf0e10cSrcweir case BOX_LINE_BOTTOM:
2431cdf0e10cSrcweir delete pBottom;
2432cdf0e10cSrcweir pBottom = pTmp;
2433cdf0e10cSrcweir break;
2434cdf0e10cSrcweir case BOX_LINE_LEFT:
2435cdf0e10cSrcweir delete pLeft;
2436cdf0e10cSrcweir pLeft = pTmp;
2437cdf0e10cSrcweir break;
2438cdf0e10cSrcweir case BOX_LINE_RIGHT:
2439cdf0e10cSrcweir delete pRight;
2440cdf0e10cSrcweir pRight = pTmp;
2441cdf0e10cSrcweir break;
2442cdf0e10cSrcweir default:
2443cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2444cdf0e10cSrcweir }
2445cdf0e10cSrcweir }
2446cdf0e10cSrcweir
2447cdf0e10cSrcweir // -----------------------------------------------------------------------
2448cdf0e10cSrcweir
GetDistance() const2449cdf0e10cSrcweir sal_uInt16 SvxBoxItem::GetDistance() const
2450cdf0e10cSrcweir {
2451cdf0e10cSrcweir // The smallest distance that is not 0 will be returned.
2452cdf0e10cSrcweir sal_uInt16 nDist = nTopDist;
2453cdf0e10cSrcweir if( nBottomDist && (!nDist || nBottomDist < nDist) )
2454cdf0e10cSrcweir nDist = nBottomDist;
2455cdf0e10cSrcweir if( nLeftDist && (!nDist || nLeftDist < nDist) )
2456cdf0e10cSrcweir nDist = nLeftDist;
2457cdf0e10cSrcweir if( nRightDist && (!nDist || nRightDist < nDist) )
2458cdf0e10cSrcweir nDist = nRightDist;
2459cdf0e10cSrcweir
2460cdf0e10cSrcweir return nDist;
2461cdf0e10cSrcweir }
2462cdf0e10cSrcweir
2463cdf0e10cSrcweir // -----------------------------------------------------------------------
2464cdf0e10cSrcweir
GetDistance(sal_uInt16 nLine) const2465cdf0e10cSrcweir sal_uInt16 SvxBoxItem::GetDistance( sal_uInt16 nLine ) const
2466cdf0e10cSrcweir {
2467cdf0e10cSrcweir sal_uInt16 nDist = 0;
2468cdf0e10cSrcweir switch ( nLine )
2469cdf0e10cSrcweir {
2470cdf0e10cSrcweir case BOX_LINE_TOP:
2471cdf0e10cSrcweir nDist = nTopDist;
2472cdf0e10cSrcweir break;
2473cdf0e10cSrcweir case BOX_LINE_BOTTOM:
2474cdf0e10cSrcweir nDist = nBottomDist;
2475cdf0e10cSrcweir break;
2476cdf0e10cSrcweir case BOX_LINE_LEFT:
2477cdf0e10cSrcweir nDist = nLeftDist;
2478cdf0e10cSrcweir break;
2479cdf0e10cSrcweir case BOX_LINE_RIGHT:
2480cdf0e10cSrcweir nDist = nRightDist;
2481cdf0e10cSrcweir break;
2482cdf0e10cSrcweir default:
2483cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2484cdf0e10cSrcweir }
2485cdf0e10cSrcweir
2486cdf0e10cSrcweir return nDist;
2487cdf0e10cSrcweir }
2488cdf0e10cSrcweir
2489cdf0e10cSrcweir // -----------------------------------------------------------------------
2490cdf0e10cSrcweir
SetDistance(sal_uInt16 nNew,sal_uInt16 nLine)2491cdf0e10cSrcweir void SvxBoxItem::SetDistance( sal_uInt16 nNew, sal_uInt16 nLine )
2492cdf0e10cSrcweir {
2493cdf0e10cSrcweir switch ( nLine )
2494cdf0e10cSrcweir {
2495cdf0e10cSrcweir case BOX_LINE_TOP:
2496cdf0e10cSrcweir nTopDist = nNew;
2497cdf0e10cSrcweir break;
2498cdf0e10cSrcweir case BOX_LINE_BOTTOM:
2499cdf0e10cSrcweir nBottomDist = nNew;
2500cdf0e10cSrcweir break;
2501cdf0e10cSrcweir case BOX_LINE_LEFT:
2502cdf0e10cSrcweir nLeftDist = nNew;
2503cdf0e10cSrcweir break;
2504cdf0e10cSrcweir case BOX_LINE_RIGHT:
2505cdf0e10cSrcweir nRightDist = nNew;
2506cdf0e10cSrcweir break;
2507cdf0e10cSrcweir default:
2508cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2509cdf0e10cSrcweir }
2510cdf0e10cSrcweir }
2511cdf0e10cSrcweir
2512cdf0e10cSrcweir // -----------------------------------------------------------------------
2513cdf0e10cSrcweir
CalcLineSpace(sal_uInt16 nLine,sal_Bool bIgnoreLine) const2514cdf0e10cSrcweir sal_uInt16 SvxBoxItem::CalcLineSpace( sal_uInt16 nLine, sal_Bool bIgnoreLine ) const
2515cdf0e10cSrcweir {
2516cdf0e10cSrcweir SvxBorderLine* pTmp = 0;
2517cdf0e10cSrcweir sal_uInt16 nDist = 0;
2518cdf0e10cSrcweir switch ( nLine )
2519cdf0e10cSrcweir {
2520cdf0e10cSrcweir case BOX_LINE_TOP:
2521cdf0e10cSrcweir pTmp = pTop;
2522cdf0e10cSrcweir nDist = nTopDist;
2523cdf0e10cSrcweir break;
2524cdf0e10cSrcweir case BOX_LINE_BOTTOM:
2525cdf0e10cSrcweir pTmp = pBottom;
2526cdf0e10cSrcweir nDist = nBottomDist;
2527cdf0e10cSrcweir break;
2528cdf0e10cSrcweir case BOX_LINE_LEFT:
2529cdf0e10cSrcweir pTmp = pLeft;
2530cdf0e10cSrcweir nDist = nLeftDist;
2531cdf0e10cSrcweir break;
2532cdf0e10cSrcweir case BOX_LINE_RIGHT:
2533cdf0e10cSrcweir pTmp = pRight;
2534cdf0e10cSrcweir nDist = nRightDist;
2535cdf0e10cSrcweir break;
2536cdf0e10cSrcweir default:
2537cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2538cdf0e10cSrcweir }
2539cdf0e10cSrcweir
2540cdf0e10cSrcweir if( pTmp )
2541cdf0e10cSrcweir {
2542cdf0e10cSrcweir nDist = nDist + (sal_uInt16)(pTmp->GetOutWidth()) + (sal_uInt16)(pTmp->GetInWidth()) + (sal_uInt16)(pTmp->GetDistance());
2543cdf0e10cSrcweir }
2544cdf0e10cSrcweir else if( !bIgnoreLine )
2545cdf0e10cSrcweir nDist = 0;
2546cdf0e10cSrcweir return nDist;
2547cdf0e10cSrcweir }
2548cdf0e10cSrcweir
2549cdf0e10cSrcweir // class SvxBoxInfoItem --------------------------------------------------
2550cdf0e10cSrcweir
SvxBoxInfoItem(const sal_uInt16 nId)2551cdf0e10cSrcweir SvxBoxInfoItem::SvxBoxInfoItem( const sal_uInt16 nId ) :
2552cdf0e10cSrcweir SfxPoolItem( nId ),
2553cdf0e10cSrcweir pHori ( 0 ),
2554cdf0e10cSrcweir pVert ( 0 ),
2555cdf0e10cSrcweir mbEnableHor( false ),
2556cdf0e10cSrcweir mbEnableVer( false ),
2557cdf0e10cSrcweir nDefDist( 0 )
2558cdf0e10cSrcweir {
2559cdf0e10cSrcweir bDist = bMinDist = sal_False;
2560cdf0e10cSrcweir ResetFlags();
2561cdf0e10cSrcweir }
2562cdf0e10cSrcweir
2563cdf0e10cSrcweir // -----------------------------------------------------------------------
2564cdf0e10cSrcweir
SvxBoxInfoItem(const SvxBoxInfoItem & rCpy)2565cdf0e10cSrcweir SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCpy ) :
2566cdf0e10cSrcweir SfxPoolItem( rCpy ),
2567cdf0e10cSrcweir mbEnableHor( rCpy.mbEnableHor ),
2568cdf0e10cSrcweir mbEnableVer( rCpy.mbEnableVer )
2569cdf0e10cSrcweir {
2570cdf0e10cSrcweir pHori = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
2571cdf0e10cSrcweir pVert = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
2572cdf0e10cSrcweir bDist = rCpy.IsDist();
2573cdf0e10cSrcweir bMinDist = rCpy.IsMinDist();
2574cdf0e10cSrcweir nValidFlags = rCpy.nValidFlags;
2575cdf0e10cSrcweir nDefDist = rCpy.GetDefDist();
2576cdf0e10cSrcweir }
2577cdf0e10cSrcweir
2578cdf0e10cSrcweir // -----------------------------------------------------------------------
2579cdf0e10cSrcweir
~SvxBoxInfoItem()2580cdf0e10cSrcweir SvxBoxInfoItem::~SvxBoxInfoItem()
2581cdf0e10cSrcweir {
2582cdf0e10cSrcweir delete pHori;
2583cdf0e10cSrcweir delete pVert;
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir
2586cdf0e10cSrcweir // -----------------------------------------------------------------------
2587cdf0e10cSrcweir
operator =(const SvxBoxInfoItem & rCpy)2588cdf0e10cSrcweir SvxBoxInfoItem &SvxBoxInfoItem::operator=( const SvxBoxInfoItem& rCpy )
2589cdf0e10cSrcweir {
2590cdf0e10cSrcweir delete pHori;
2591cdf0e10cSrcweir delete pVert;
2592cdf0e10cSrcweir pHori = rCpy.GetHori() ? new SvxBorderLine( *rCpy.GetHori() ) : 0;
2593cdf0e10cSrcweir pVert = rCpy.GetVert() ? new SvxBorderLine( *rCpy.GetVert() ) : 0;
2594cdf0e10cSrcweir mbEnableHor = rCpy.mbEnableHor;
2595cdf0e10cSrcweir mbEnableVer = rCpy.mbEnableVer;
2596cdf0e10cSrcweir bDist = rCpy.IsDist();
2597cdf0e10cSrcweir bMinDist = rCpy.IsMinDist();
2598cdf0e10cSrcweir nValidFlags = rCpy.nValidFlags;
2599cdf0e10cSrcweir nDefDist = rCpy.GetDefDist();
2600cdf0e10cSrcweir return *this;
2601cdf0e10cSrcweir }
2602cdf0e10cSrcweir
2603cdf0e10cSrcweir // -----------------------------------------------------------------------
2604cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const2605cdf0e10cSrcweir int SvxBoxInfoItem::operator==( const SfxPoolItem& rAttr ) const
2606cdf0e10cSrcweir {
2607cdf0e10cSrcweir SvxBoxInfoItem& rBoxInfo = (SvxBoxInfoItem&)rAttr;
2608cdf0e10cSrcweir
2609cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
2610cdf0e10cSrcweir
2611cdf0e10cSrcweir return ( mbEnableHor == rBoxInfo.mbEnableHor
2612cdf0e10cSrcweir && mbEnableVer == rBoxInfo.mbEnableVer
2613cdf0e10cSrcweir && bDist == rBoxInfo.IsDist()
2614cdf0e10cSrcweir && bMinDist == rBoxInfo.IsMinDist()
2615cdf0e10cSrcweir && nValidFlags == rBoxInfo.nValidFlags
2616cdf0e10cSrcweir && nDefDist == rBoxInfo.GetDefDist()
2617cdf0e10cSrcweir && CmpBrdLn( pHori, rBoxInfo.GetHori() )
2618cdf0e10cSrcweir && CmpBrdLn( pVert, rBoxInfo.GetVert() )
2619cdf0e10cSrcweir );
2620cdf0e10cSrcweir }
2621cdf0e10cSrcweir
2622cdf0e10cSrcweir // -----------------------------------------------------------------------
2623cdf0e10cSrcweir
SetLine(const SvxBorderLine * pNew,sal_uInt16 nLine)2624cdf0e10cSrcweir void SvxBoxInfoItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )
2625cdf0e10cSrcweir {
2626cdf0e10cSrcweir SvxBorderLine* pTmp = pNew ? new SvxBorderLine( *pNew ) : 0;
2627cdf0e10cSrcweir
2628cdf0e10cSrcweir if ( BOXINFO_LINE_HORI == nLine )
2629cdf0e10cSrcweir {
2630cdf0e10cSrcweir delete pHori;
2631cdf0e10cSrcweir pHori = pTmp;
2632cdf0e10cSrcweir }
2633cdf0e10cSrcweir else if ( BOXINFO_LINE_VERT == nLine )
2634cdf0e10cSrcweir {
2635cdf0e10cSrcweir delete pVert;
2636cdf0e10cSrcweir pVert = pTmp;
2637cdf0e10cSrcweir }
2638cdf0e10cSrcweir else
2639cdf0e10cSrcweir {
2640cdf0e10cSrcweir DBG_ERROR( "wrong line" );
2641cdf0e10cSrcweir }
2642cdf0e10cSrcweir }
2643cdf0e10cSrcweir
2644cdf0e10cSrcweir
2645cdf0e10cSrcweir // -----------------------------------------------------------------------
2646cdf0e10cSrcweir
Clone(SfxItemPool *) const2647cdf0e10cSrcweir SfxPoolItem* SvxBoxInfoItem::Clone( SfxItemPool* ) const
2648cdf0e10cSrcweir {
2649cdf0e10cSrcweir return new SvxBoxInfoItem( *this );
2650cdf0e10cSrcweir }
2651cdf0e10cSrcweir
2652cdf0e10cSrcweir //------------------------------------------------------------------------
2653cdf0e10cSrcweir
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const2654cdf0e10cSrcweir SfxItemPresentation SvxBoxInfoItem::GetPresentation
2655cdf0e10cSrcweir (
2656cdf0e10cSrcweir SfxItemPresentation /*ePres*/,
2657cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
2658cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
2659cdf0e10cSrcweir XubString& rText, const IntlWrapper *
2660cdf0e10cSrcweir ) const
2661cdf0e10cSrcweir {
2662cdf0e10cSrcweir #ifndef SVX_LIGHT
2663cdf0e10cSrcweir /*!!!
2664cdf0e10cSrcweir ResMgr* pMgr = DIALOG_MGR();
2665cdf0e10cSrcweir if ( pHori )
2666cdf0e10cSrcweir {
2667cdf0e10cSrcweir rText += pHori->GetValueString();
2668cdf0e10cSrcweir rText += cpDelim;
2669cdf0e10cSrcweir }
2670cdf0e10cSrcweir if ( pVert )
2671cdf0e10cSrcweir {
2672cdf0e10cSrcweir rText += pVert->GetValueString();
2673cdf0e10cSrcweir rText += cpDelim;
2674cdf0e10cSrcweir }
2675cdf0e10cSrcweir if ( bTable )
2676cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_TRUE, pMgr ) );
2677cdf0e10cSrcweir else
2678cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_TABLE_FALSE, pMgr ) );
2679cdf0e10cSrcweir rText += cpDelim;
2680cdf0e10cSrcweir if ( bDist )
2681cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_TRUE, pMgr ) );
2682cdf0e10cSrcweir else
2683cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_DIST_FALSE, pMgr ) );
2684cdf0e10cSrcweir rText += cpDelim;
2685cdf0e10cSrcweir if ( bMinDist )
2686cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_TRUE, pMgr ) );
2687cdf0e10cSrcweir else
2688cdf0e10cSrcweir rText += String( ResId( RID_SVXITEMS_BOXINF_MDIST_FALSE, pMgr ) );
2689cdf0e10cSrcweir rText += cpDelim;
2690cdf0e10cSrcweir rText += nDefDist;
2691cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS;
2692cdf0e10cSrcweir */
2693cdf0e10cSrcweir rText.Erase();
2694cdf0e10cSrcweir #endif // !SVX_LIGHT
2695cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
2696cdf0e10cSrcweir }
2697cdf0e10cSrcweir
2698cdf0e10cSrcweir // -----------------------------------------------------------------------
2699cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const2700cdf0e10cSrcweir SvStream& SvxBoxInfoItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
2701cdf0e10cSrcweir {
2702cdf0e10cSrcweir sal_Int8 cFlags = 0;
2703cdf0e10cSrcweir
2704cdf0e10cSrcweir if ( IsTable() )
2705cdf0e10cSrcweir cFlags |= 0x01;
2706cdf0e10cSrcweir if ( IsDist() )
2707cdf0e10cSrcweir cFlags |= 0x02;
2708cdf0e10cSrcweir if ( IsMinDist() )
2709cdf0e10cSrcweir cFlags |= 0x04;
2710cdf0e10cSrcweir rStrm << (sal_Int8) cFlags
2711cdf0e10cSrcweir << (sal_uInt16) GetDefDist();
2712cdf0e10cSrcweir const SvxBorderLine* pLine[ 2 ];
2713cdf0e10cSrcweir pLine[ 0 ] = GetHori();
2714cdf0e10cSrcweir pLine[ 1 ] = GetVert();
2715cdf0e10cSrcweir
2716cdf0e10cSrcweir for( int i = 0; i < 2; i++ )
2717cdf0e10cSrcweir {
2718cdf0e10cSrcweir const SvxBorderLine* l = pLine[ i ];
2719cdf0e10cSrcweir if( l )
2720cdf0e10cSrcweir {
2721cdf0e10cSrcweir rStrm << (char) i
2722cdf0e10cSrcweir << l->GetColor()
2723cdf0e10cSrcweir << (short) l->GetOutWidth()
2724cdf0e10cSrcweir << (short) l->GetInWidth()
2725cdf0e10cSrcweir << (short) l->GetDistance();
2726cdf0e10cSrcweir }
2727cdf0e10cSrcweir }
2728cdf0e10cSrcweir rStrm << (char) 2;
2729cdf0e10cSrcweir return rStrm;
2730cdf0e10cSrcweir }
2731cdf0e10cSrcweir
2732cdf0e10cSrcweir // -----------------------------------------------------------------------
2733cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)2734cdf0e10cSrcweir int SvxBoxInfoItem::ScaleMetrics( long nMult, long nDiv )
2735cdf0e10cSrcweir {
2736cdf0e10cSrcweir if ( pHori ) pHori->ScaleMetrics( nMult, nDiv );
2737cdf0e10cSrcweir if ( pVert ) pVert->ScaleMetrics( nMult, nDiv );
2738cdf0e10cSrcweir nDefDist = (sal_uInt16)Scale( nDefDist, nMult, nDiv );
2739cdf0e10cSrcweir return 1;
2740cdf0e10cSrcweir }
2741cdf0e10cSrcweir
2742cdf0e10cSrcweir // -----------------------------------------------------------------------
2743cdf0e10cSrcweir
HasMetrics() const2744cdf0e10cSrcweir int SvxBoxInfoItem::HasMetrics() const
2745cdf0e10cSrcweir {
2746cdf0e10cSrcweir return 1;
2747cdf0e10cSrcweir }
2748cdf0e10cSrcweir
2749cdf0e10cSrcweir // -----------------------------------------------------------------------
2750cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const2751cdf0e10cSrcweir SfxPoolItem* SvxBoxInfoItem::Create( SvStream& rStrm, sal_uInt16 ) const
2752cdf0e10cSrcweir {
2753cdf0e10cSrcweir sal_Int8 cFlags;
2754cdf0e10cSrcweir sal_uInt16 _nDefDist;
2755cdf0e10cSrcweir rStrm >> cFlags >> _nDefDist;
2756cdf0e10cSrcweir
2757cdf0e10cSrcweir SvxBoxInfoItem* pAttr = new SvxBoxInfoItem( Which() );
2758cdf0e10cSrcweir
2759cdf0e10cSrcweir pAttr->SetTable ( ( cFlags & 0x01 ) != 0 );
2760cdf0e10cSrcweir pAttr->SetDist ( ( cFlags & 0x02 ) != 0 );
2761cdf0e10cSrcweir pAttr->SetMinDist( ( cFlags & 0x04 ) != 0 );
2762cdf0e10cSrcweir pAttr->SetDefDist( _nDefDist );
2763cdf0e10cSrcweir
2764cdf0e10cSrcweir while( sal_True )
2765cdf0e10cSrcweir {
2766cdf0e10cSrcweir sal_Int8 cLine;
2767cdf0e10cSrcweir rStrm >> cLine;
2768cdf0e10cSrcweir
2769cdf0e10cSrcweir if( cLine > 1 )
2770cdf0e10cSrcweir break;
2771cdf0e10cSrcweir short nOutline, nInline, nDistance;
2772cdf0e10cSrcweir Color aColor;
2773cdf0e10cSrcweir rStrm >> aColor >> nOutline >> nInline >> nDistance;
2774cdf0e10cSrcweir SvxBorderLine aBorder( &aColor, nOutline, nInline, nDistance );
2775cdf0e10cSrcweir
2776cdf0e10cSrcweir switch( cLine )
2777cdf0e10cSrcweir {
2778cdf0e10cSrcweir case 0: pAttr->SetLine( &aBorder, BOXINFO_LINE_HORI ); break;
2779cdf0e10cSrcweir case 1: pAttr->SetLine( &aBorder, BOXINFO_LINE_VERT ); break;
2780cdf0e10cSrcweir }
2781cdf0e10cSrcweir }
2782cdf0e10cSrcweir return pAttr;
2783cdf0e10cSrcweir }
2784cdf0e10cSrcweir
2785cdf0e10cSrcweir // -----------------------------------------------------------------------
2786cdf0e10cSrcweir
ResetFlags()2787cdf0e10cSrcweir void SvxBoxInfoItem::ResetFlags()
2788cdf0e10cSrcweir {
2789cdf0e10cSrcweir nValidFlags = 0x7F; // alles g"ultig au/ser Disable
2790cdf0e10cSrcweir }
2791cdf0e10cSrcweir
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const2792cdf0e10cSrcweir sal_Bool SvxBoxInfoItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
2793cdf0e10cSrcweir {
2794cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2795cdf0e10cSrcweir table::BorderLine aRetLine;
2796cdf0e10cSrcweir sal_Int16 nVal=0;
2797cdf0e10cSrcweir sal_Bool bIntMember = sal_False;
2798cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
2799cdf0e10cSrcweir sal_Bool bSerialize = sal_False;
2800cdf0e10cSrcweir switch(nMemberId)
2801cdf0e10cSrcweir {
2802cdf0e10cSrcweir case 0:
2803cdf0e10cSrcweir {
2804cdf0e10cSrcweir // 2 BorderLines, flags, valid flags and distance
2805cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq( 5 );
2806cdf0e10cSrcweir aSeq[0] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pHori, bConvert) );
2807cdf0e10cSrcweir aSeq[1] = ::com::sun::star::uno::makeAny( SvxBoxItem::SvxLineToLine( pVert, bConvert) );
2808cdf0e10cSrcweir if ( IsTable() )
2809cdf0e10cSrcweir nVal |= 0x01;
2810cdf0e10cSrcweir if ( IsDist() )
2811cdf0e10cSrcweir nVal |= 0x02;
2812cdf0e10cSrcweir if ( IsMinDist() )
2813cdf0e10cSrcweir nVal |= 0x04;
2814cdf0e10cSrcweir aSeq[2] = ::com::sun::star::uno::makeAny( nVal );
2815cdf0e10cSrcweir nVal = nValidFlags;
2816cdf0e10cSrcweir aSeq[3] = ::com::sun::star::uno::makeAny( nVal );
2817cdf0e10cSrcweir aSeq[4] = ::com::sun::star::uno::makeAny( (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist()) );
2818cdf0e10cSrcweir rVal = ::com::sun::star::uno::makeAny( aSeq );
2819cdf0e10cSrcweir return sal_True;
2820cdf0e10cSrcweir }
2821cdf0e10cSrcweir
2822cdf0e10cSrcweir case MID_HORIZONTAL:
2823cdf0e10cSrcweir bSerialize = sal_True;
2824cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine( pHori, bConvert);
2825cdf0e10cSrcweir break;
2826cdf0e10cSrcweir case MID_VERTICAL:
2827cdf0e10cSrcweir bSerialize = sal_True;
2828cdf0e10cSrcweir aRetLine = SvxBoxItem::SvxLineToLine( pVert, bConvert);
2829cdf0e10cSrcweir break;
2830cdf0e10cSrcweir case MID_FLAGS:
2831cdf0e10cSrcweir bIntMember = sal_True;
2832cdf0e10cSrcweir if ( IsTable() )
2833cdf0e10cSrcweir nVal |= 0x01;
2834cdf0e10cSrcweir if ( IsDist() )
2835cdf0e10cSrcweir nVal |= 0x02;
2836cdf0e10cSrcweir if ( IsMinDist() )
2837cdf0e10cSrcweir nVal |= 0x04;
2838cdf0e10cSrcweir rVal <<= nVal;
2839cdf0e10cSrcweir break;
2840cdf0e10cSrcweir case MID_VALIDFLAGS:
2841cdf0e10cSrcweir bIntMember = sal_True;
2842cdf0e10cSrcweir nVal = nValidFlags;
2843cdf0e10cSrcweir rVal <<= nVal;
2844cdf0e10cSrcweir break;
2845cdf0e10cSrcweir case MID_DISTANCE:
2846cdf0e10cSrcweir bIntMember = sal_True;
2847cdf0e10cSrcweir rVal <<= (sal_Int32)(bConvert ? TWIP_TO_MM100_UNSIGNED(GetDefDist()) : GetDefDist());
2848cdf0e10cSrcweir break;
2849cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!"); return sal_False;
2850cdf0e10cSrcweir }
2851cdf0e10cSrcweir
2852cdf0e10cSrcweir if( !bIntMember )
2853cdf0e10cSrcweir {
2854cdf0e10cSrcweir /*
2855cdf0e10cSrcweir if ( bSerialize )
2856cdf0e10cSrcweir {
2857cdf0e10cSrcweir ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Any > aSeq(4);
2858cdf0e10cSrcweir aSeq[0] <<= aRetLine.Color;
2859cdf0e10cSrcweir aSeq[1] <<= aRetLine.InnerLineWidth;
2860cdf0e10cSrcweir aSeq[2] <<= aRetLine.OuterLineWidth;
2861cdf0e10cSrcweir aSeq[3] <<= aRetLine.LineDistance;
2862cdf0e10cSrcweir rVal <<= aSeq;
2863cdf0e10cSrcweir }
2864cdf0e10cSrcweir else
2865cdf0e10cSrcweir */
2866cdf0e10cSrcweir rVal <<= aRetLine;
2867cdf0e10cSrcweir }
2868cdf0e10cSrcweir
2869cdf0e10cSrcweir return sal_True;
2870cdf0e10cSrcweir }
2871cdf0e10cSrcweir
2872cdf0e10cSrcweir // -----------------------------------------------------------------------
2873cdf0e10cSrcweir
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)2874cdf0e10cSrcweir sal_Bool SvxBoxInfoItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
2875cdf0e10cSrcweir {
2876cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
2877cdf0e10cSrcweir // sal_uInt16 nLine = BOX_LINE_TOP;
2878cdf0e10cSrcweir // sal_Bool bDistMember = sal_False;
2879cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
2880cdf0e10cSrcweir sal_Bool bRet;
2881cdf0e10cSrcweir switch(nMemberId)
2882cdf0e10cSrcweir {
2883cdf0e10cSrcweir case 0:
2884cdf0e10cSrcweir {
2885cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aSeq;
2886cdf0e10cSrcweir if (( rVal >>= aSeq ) && ( aSeq.getLength() == 5 ))
2887cdf0e10cSrcweir {
2888cdf0e10cSrcweir // 2 BorderLines, flags, valid flags and distance
2889cdf0e10cSrcweir table::BorderLine aBorderLine;
2890cdf0e10cSrcweir SvxBorderLine aLine;
2891cdf0e10cSrcweir sal_Int16 nFlags( 0 );
2892cdf0e10cSrcweir sal_Int32 nVal( 0 );
2893cdf0e10cSrcweir if ( aSeq[0] >>= aBorderLine )
2894cdf0e10cSrcweir {
2895cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2896cdf0e10cSrcweir if ( bSet )
2897cdf0e10cSrcweir SetLine( &aLine, BOXINFO_LINE_HORI );
2898cdf0e10cSrcweir }
2899cdf0e10cSrcweir else
2900cdf0e10cSrcweir return sal_False;
2901cdf0e10cSrcweir if ( aSeq[1] >>= aBorderLine )
2902cdf0e10cSrcweir {
2903cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2904cdf0e10cSrcweir if ( bSet )
2905cdf0e10cSrcweir SetLine( &aLine, BOXINFO_LINE_VERT );
2906cdf0e10cSrcweir }
2907cdf0e10cSrcweir else
2908cdf0e10cSrcweir return sal_False;
2909cdf0e10cSrcweir if ( aSeq[2] >>= nFlags )
2910cdf0e10cSrcweir {
2911cdf0e10cSrcweir SetTable ( ( nFlags & 0x01 ) != 0 );
2912cdf0e10cSrcweir SetDist ( ( nFlags & 0x02 ) != 0 );
2913cdf0e10cSrcweir SetMinDist( ( nFlags & 0x04 ) != 0 );
2914cdf0e10cSrcweir }
2915cdf0e10cSrcweir else
2916cdf0e10cSrcweir return sal_False;
2917cdf0e10cSrcweir if ( aSeq[3] >>= nFlags )
2918cdf0e10cSrcweir nValidFlags = (sal_uInt8)nFlags;
2919cdf0e10cSrcweir else
2920cdf0e10cSrcweir return sal_False;
2921cdf0e10cSrcweir if (( aSeq[4] >>= nVal ) && ( nVal >= 0 ))
2922cdf0e10cSrcweir {
2923cdf0e10cSrcweir if( bConvert )
2924cdf0e10cSrcweir nVal = MM100_TO_TWIP(nVal);
2925cdf0e10cSrcweir SetDefDist( (sal_uInt16)nVal );
2926cdf0e10cSrcweir }
2927cdf0e10cSrcweir }
2928cdf0e10cSrcweir return sal_True;
2929cdf0e10cSrcweir }
2930cdf0e10cSrcweir
2931cdf0e10cSrcweir case MID_HORIZONTAL:
2932cdf0e10cSrcweir case MID_VERTICAL:
2933cdf0e10cSrcweir {
2934cdf0e10cSrcweir if( !rVal.hasValue() )
2935cdf0e10cSrcweir return sal_False;
2936cdf0e10cSrcweir
2937cdf0e10cSrcweir table::BorderLine aBorderLine;
2938cdf0e10cSrcweir if( rVal >>= aBorderLine )
2939cdf0e10cSrcweir {
2940cdf0e10cSrcweir // usual struct
2941cdf0e10cSrcweir }
2942cdf0e10cSrcweir else if (rVal.getValueTypeClass() == uno::TypeClass_SEQUENCE )
2943cdf0e10cSrcweir {
2944cdf0e10cSrcweir // serialization for basic macro recording
2945cdf0e10cSrcweir uno::Reference < script::XTypeConverter > xConverter
2946cdf0e10cSrcweir ( ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.script.Converter")),
2947cdf0e10cSrcweir uno::UNO_QUERY );
2948cdf0e10cSrcweir uno::Any aNew;
2949cdf0e10cSrcweir uno::Sequence < uno::Any > aSeq;
2950cdf0e10cSrcweir try { aNew = xConverter->convertTo( rVal, ::getCppuType((const uno::Sequence < uno::Any >*)0) ); }
2951cdf0e10cSrcweir catch (uno::Exception&) {}
2952cdf0e10cSrcweir
2953cdf0e10cSrcweir if( (aNew >>= aSeq) && aSeq.getLength() == 4 )
2954cdf0e10cSrcweir {
2955cdf0e10cSrcweir sal_Int32 nVal = 0;
2956cdf0e10cSrcweir if ( aSeq[0] >>= nVal )
2957cdf0e10cSrcweir aBorderLine.Color = nVal;
2958cdf0e10cSrcweir if ( aSeq[1] >>= nVal )
2959cdf0e10cSrcweir aBorderLine.InnerLineWidth = (sal_Int16) nVal;
2960cdf0e10cSrcweir if ( aSeq[2] >>= nVal )
2961cdf0e10cSrcweir aBorderLine.OuterLineWidth = (sal_Int16) nVal;
2962cdf0e10cSrcweir if ( aSeq[3] >>= nVal )
2963cdf0e10cSrcweir aBorderLine.LineDistance = (sal_Int16) nVal;
2964cdf0e10cSrcweir }
2965cdf0e10cSrcweir else
2966cdf0e10cSrcweir return sal_False;
2967cdf0e10cSrcweir }
2968cdf0e10cSrcweir else if (rVal.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < sal_Int16 >*)0) )
2969cdf0e10cSrcweir {
2970cdf0e10cSrcweir // serialization for basic macro recording
2971cdf0e10cSrcweir ::com::sun::star::uno::Sequence < sal_Int16 > aSeq;
2972cdf0e10cSrcweir rVal >>= aSeq;
2973cdf0e10cSrcweir if ( aSeq.getLength() == 4 )
2974cdf0e10cSrcweir {
2975cdf0e10cSrcweir aBorderLine.Color = aSeq[0];
2976cdf0e10cSrcweir aBorderLine.InnerLineWidth = aSeq[1];
2977cdf0e10cSrcweir aBorderLine.OuterLineWidth = aSeq[2];
2978cdf0e10cSrcweir aBorderLine.LineDistance = aSeq[3];
2979cdf0e10cSrcweir }
2980cdf0e10cSrcweir else
2981cdf0e10cSrcweir return sal_False;
2982cdf0e10cSrcweir }
2983cdf0e10cSrcweir else
2984cdf0e10cSrcweir return sal_False;
2985cdf0e10cSrcweir
2986cdf0e10cSrcweir SvxBorderLine aLine;
2987cdf0e10cSrcweir sal_Bool bSet = SvxBoxItem::LineToSvxLine(aBorderLine, aLine, bConvert);
2988cdf0e10cSrcweir if ( bSet )
2989cdf0e10cSrcweir SetLine( &aLine, nMemberId == MID_HORIZONTAL ? BOXINFO_LINE_HORI : BOXINFO_LINE_VERT );
2990cdf0e10cSrcweir break;
2991cdf0e10cSrcweir }
2992cdf0e10cSrcweir case MID_FLAGS:
2993cdf0e10cSrcweir {
2994cdf0e10cSrcweir sal_Int16 nFlags = sal_Int16();
2995cdf0e10cSrcweir bRet = (rVal >>= nFlags);
2996cdf0e10cSrcweir if ( bRet )
2997cdf0e10cSrcweir {
2998cdf0e10cSrcweir SetTable ( ( nFlags & 0x01 ) != 0 );
2999cdf0e10cSrcweir SetDist ( ( nFlags & 0x02 ) != 0 );
3000cdf0e10cSrcweir SetMinDist( ( nFlags & 0x04 ) != 0 );
3001cdf0e10cSrcweir }
3002cdf0e10cSrcweir
3003cdf0e10cSrcweir break;
3004cdf0e10cSrcweir }
3005cdf0e10cSrcweir case MID_VALIDFLAGS:
3006cdf0e10cSrcweir {
3007cdf0e10cSrcweir sal_Int16 nFlags = sal_Int16();
3008cdf0e10cSrcweir bRet = (rVal >>= nFlags);
3009cdf0e10cSrcweir if ( bRet )
3010cdf0e10cSrcweir nValidFlags = (sal_uInt8)nFlags;
3011cdf0e10cSrcweir break;
3012cdf0e10cSrcweir }
3013cdf0e10cSrcweir case MID_DISTANCE:
3014cdf0e10cSrcweir {
3015cdf0e10cSrcweir sal_Int32 nVal = 0;
3016cdf0e10cSrcweir bRet = (rVal >>= nVal);
3017cdf0e10cSrcweir if ( bRet && nVal>=0 )
3018cdf0e10cSrcweir {
3019cdf0e10cSrcweir if( bConvert )
3020cdf0e10cSrcweir nVal = MM100_TO_TWIP(nVal);
3021cdf0e10cSrcweir SetDefDist( (sal_uInt16)nVal );
3022cdf0e10cSrcweir }
3023cdf0e10cSrcweir break;
3024cdf0e10cSrcweir }
3025cdf0e10cSrcweir default: DBG_ERROR("Wrong MemberId!"); return sal_False;
3026cdf0e10cSrcweir }
3027cdf0e10cSrcweir
3028cdf0e10cSrcweir return sal_True;
3029cdf0e10cSrcweir }
3030cdf0e10cSrcweir
3031cdf0e10cSrcweir // class SvxFmtBreakItem -------------------------------------------------
3032cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const3033cdf0e10cSrcweir int SvxFmtBreakItem::operator==( const SfxPoolItem& rAttr ) const
3034cdf0e10cSrcweir {
3035cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "unequal types" );
3036cdf0e10cSrcweir
3037cdf0e10cSrcweir return GetValue() == ( (SvxFmtBreakItem&)rAttr ).GetValue();
3038cdf0e10cSrcweir }
3039cdf0e10cSrcweir
3040cdf0e10cSrcweir //------------------------------------------------------------------------
3041cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3042cdf0e10cSrcweir SfxItemPresentation SvxFmtBreakItem::GetPresentation
3043cdf0e10cSrcweir (
3044cdf0e10cSrcweir SfxItemPresentation ePres,
3045cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
3046cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
3047cdf0e10cSrcweir XubString& rText, const IntlWrapper *
3048cdf0e10cSrcweir ) const
3049cdf0e10cSrcweir {
3050cdf0e10cSrcweir #ifndef SVX_LIGHT
3051cdf0e10cSrcweir switch ( ePres )
3052cdf0e10cSrcweir {
3053cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
3054cdf0e10cSrcweir rText.Erase();
3055cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3056cdf0e10cSrcweir
3057cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
3058cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
3059cdf0e10cSrcweir rText = GetValueTextByPos( GetValue() );
3060cdf0e10cSrcweir return ePres;
3061cdf0e10cSrcweir default: ;//prevent warning
3062cdf0e10cSrcweir }
3063cdf0e10cSrcweir #endif // !SVX_LIGHT
3064cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3065cdf0e10cSrcweir }
3066cdf0e10cSrcweir
3067cdf0e10cSrcweir // -----------------------------------------------------------------------
3068cdf0e10cSrcweir
GetValueTextByPos(sal_uInt16 nPos) const3069cdf0e10cSrcweir XubString SvxFmtBreakItem::GetValueTextByPos( sal_uInt16 nPos ) const
3070cdf0e10cSrcweir {
3071cdf0e10cSrcweir DBG_ASSERT( nPos < SVX_BREAK_END, "enum overflow!" );
3072cdf0e10cSrcweir XubString aStr( EditResId( RID_SVXITEMS_BREAK_BEGIN + nPos ) );
3073cdf0e10cSrcweir return aStr;
3074cdf0e10cSrcweir }
3075cdf0e10cSrcweir
3076cdf0e10cSrcweir // -----------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8) const3077cdf0e10cSrcweir sal_Bool SvxFmtBreakItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
3078cdf0e10cSrcweir {
3079cdf0e10cSrcweir style::BreakType eBreak = style::BreakType_NONE;
3080cdf0e10cSrcweir switch ( (SvxBreak)GetValue() )
3081cdf0e10cSrcweir {
3082cdf0e10cSrcweir case SVX_BREAK_COLUMN_BEFORE: eBreak = style::BreakType_COLUMN_BEFORE; break;
3083cdf0e10cSrcweir case SVX_BREAK_COLUMN_AFTER: eBreak = style::BreakType_COLUMN_AFTER ; break;
3084cdf0e10cSrcweir case SVX_BREAK_COLUMN_BOTH: eBreak = style::BreakType_COLUMN_BOTH ; break;
3085cdf0e10cSrcweir case SVX_BREAK_PAGE_BEFORE: eBreak = style::BreakType_PAGE_BEFORE ; break;
3086cdf0e10cSrcweir case SVX_BREAK_PAGE_AFTER: eBreak = style::BreakType_PAGE_AFTER ; break;
3087cdf0e10cSrcweir case SVX_BREAK_PAGE_BOTH: eBreak = style::BreakType_PAGE_BOTH ; break;
3088cdf0e10cSrcweir default: ;//prevent warning
3089cdf0e10cSrcweir }
3090cdf0e10cSrcweir rVal <<= eBreak;
3091cdf0e10cSrcweir return sal_True;
3092cdf0e10cSrcweir }
3093cdf0e10cSrcweir // -----------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8)3094cdf0e10cSrcweir sal_Bool SvxFmtBreakItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
3095cdf0e10cSrcweir {
3096cdf0e10cSrcweir style::BreakType nBreak;
3097cdf0e10cSrcweir
3098cdf0e10cSrcweir if(!(rVal >>= nBreak))
3099cdf0e10cSrcweir {
3100cdf0e10cSrcweir sal_Int32 nValue = 0;
3101cdf0e10cSrcweir if(!(rVal >>= nValue))
3102cdf0e10cSrcweir return sal_False;
3103cdf0e10cSrcweir
3104cdf0e10cSrcweir nBreak = (style::BreakType) nValue;
3105cdf0e10cSrcweir }
3106cdf0e10cSrcweir
3107cdf0e10cSrcweir SvxBreak eBreak = SVX_BREAK_NONE;
3108cdf0e10cSrcweir switch( nBreak )
3109cdf0e10cSrcweir {
3110cdf0e10cSrcweir case style::BreakType_COLUMN_BEFORE: eBreak = SVX_BREAK_COLUMN_BEFORE; break;
3111cdf0e10cSrcweir case style::BreakType_COLUMN_AFTER: eBreak = SVX_BREAK_COLUMN_AFTER; break;
3112cdf0e10cSrcweir case style::BreakType_COLUMN_BOTH: eBreak = SVX_BREAK_COLUMN_BOTH; break;
3113cdf0e10cSrcweir case style::BreakType_PAGE_BEFORE: eBreak = SVX_BREAK_PAGE_BEFORE; break;
3114cdf0e10cSrcweir case style::BreakType_PAGE_AFTER: eBreak = SVX_BREAK_PAGE_AFTER; break;
3115cdf0e10cSrcweir case style::BreakType_PAGE_BOTH: eBreak = SVX_BREAK_PAGE_BOTH; break;
3116cdf0e10cSrcweir default: ;//prevent warning
3117cdf0e10cSrcweir }
3118cdf0e10cSrcweir SetValue((sal_uInt16) eBreak);
3119cdf0e10cSrcweir
3120cdf0e10cSrcweir return sal_True;
3121cdf0e10cSrcweir }
3122cdf0e10cSrcweir
3123cdf0e10cSrcweir // -----------------------------------------------------------------------
3124cdf0e10cSrcweir
Clone(SfxItemPool *) const3125cdf0e10cSrcweir SfxPoolItem* SvxFmtBreakItem::Clone( SfxItemPool* ) const
3126cdf0e10cSrcweir {
3127cdf0e10cSrcweir return new SvxFmtBreakItem( *this );
3128cdf0e10cSrcweir }
3129cdf0e10cSrcweir
3130cdf0e10cSrcweir // -----------------------------------------------------------------------
3131cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const3132cdf0e10cSrcweir SvStream& SvxFmtBreakItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
3133cdf0e10cSrcweir {
3134cdf0e10cSrcweir rStrm << (sal_Int8)GetValue();
3135cdf0e10cSrcweir if( FMTBREAK_NOAUTO > nItemVersion )
3136cdf0e10cSrcweir rStrm << (sal_Int8)0x01;
3137cdf0e10cSrcweir return rStrm;
3138cdf0e10cSrcweir }
3139cdf0e10cSrcweir
3140cdf0e10cSrcweir // -----------------------------------------------------------------------
3141cdf0e10cSrcweir
GetVersion(sal_uInt16 nFFVer) const3142cdf0e10cSrcweir sal_uInt16 SvxFmtBreakItem::GetVersion( sal_uInt16 nFFVer ) const
3143cdf0e10cSrcweir {
3144cdf0e10cSrcweir DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
3145cdf0e10cSrcweir SOFFICE_FILEFORMAT_40==nFFVer ||
3146cdf0e10cSrcweir SOFFICE_FILEFORMAT_50==nFFVer,
3147cdf0e10cSrcweir "SvxFmtBreakItem: Gibt es ein neues Fileformat?" );
3148cdf0e10cSrcweir return SOFFICE_FILEFORMAT_31==nFFVer ||
3149cdf0e10cSrcweir SOFFICE_FILEFORMAT_40==nFFVer ? 0 : FMTBREAK_NOAUTO;
3150cdf0e10cSrcweir }
3151cdf0e10cSrcweir
3152cdf0e10cSrcweir // -----------------------------------------------------------------------
3153cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16 nVersion) const3154cdf0e10cSrcweir SfxPoolItem* SvxFmtBreakItem::Create( SvStream& rStrm, sal_uInt16 nVersion ) const
3155cdf0e10cSrcweir {
3156cdf0e10cSrcweir sal_Int8 eBreak, bDummy;
3157cdf0e10cSrcweir rStrm >> eBreak;
3158cdf0e10cSrcweir if( FMTBREAK_NOAUTO > nVersion )
3159cdf0e10cSrcweir rStrm >> bDummy;
3160cdf0e10cSrcweir return new SvxFmtBreakItem( (const SvxBreak)eBreak, Which() );
3161cdf0e10cSrcweir }
3162cdf0e10cSrcweir
3163cdf0e10cSrcweir // -----------------------------------------------------------------------
3164cdf0e10cSrcweir
GetValueCount() const3165cdf0e10cSrcweir sal_uInt16 SvxFmtBreakItem::GetValueCount() const
3166cdf0e10cSrcweir {
3167cdf0e10cSrcweir return SVX_BREAK_END; // SVX_BREAK_PAGE_BOTH + 1
3168cdf0e10cSrcweir }
3169cdf0e10cSrcweir
3170cdf0e10cSrcweir // class SvxFmtKeepItem -------------------------------------------------
3171cdf0e10cSrcweir
Clone(SfxItemPool *) const3172cdf0e10cSrcweir SfxPoolItem* SvxFmtKeepItem::Clone( SfxItemPool* ) const
3173cdf0e10cSrcweir {
3174cdf0e10cSrcweir return new SvxFmtKeepItem( *this );
3175cdf0e10cSrcweir }
3176cdf0e10cSrcweir
3177cdf0e10cSrcweir // -----------------------------------------------------------------------
3178cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const3179cdf0e10cSrcweir SvStream& SvxFmtKeepItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3180cdf0e10cSrcweir {
3181cdf0e10cSrcweir rStrm << (sal_Int8)GetValue();
3182cdf0e10cSrcweir return rStrm;
3183cdf0e10cSrcweir }
3184cdf0e10cSrcweir
3185cdf0e10cSrcweir // -----------------------------------------------------------------------
3186cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const3187cdf0e10cSrcweir SfxPoolItem* SvxFmtKeepItem::Create( SvStream& rStrm, sal_uInt16 ) const
3188cdf0e10cSrcweir {
3189cdf0e10cSrcweir sal_Int8 bIsKeep;
3190cdf0e10cSrcweir rStrm >> bIsKeep;
3191cdf0e10cSrcweir return new SvxFmtKeepItem( sal_Bool( bIsKeep != 0 ), Which() );
3192cdf0e10cSrcweir }
3193cdf0e10cSrcweir
3194cdf0e10cSrcweir //------------------------------------------------------------------------
3195cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3196cdf0e10cSrcweir SfxItemPresentation SvxFmtKeepItem::GetPresentation
3197cdf0e10cSrcweir (
3198cdf0e10cSrcweir SfxItemPresentation ePres,
3199cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
3200cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
3201cdf0e10cSrcweir XubString& rText, const IntlWrapper *
3202cdf0e10cSrcweir ) const
3203cdf0e10cSrcweir {
3204cdf0e10cSrcweir #ifndef SVX_LIGHT
3205cdf0e10cSrcweir switch ( ePres )
3206cdf0e10cSrcweir {
3207cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
3208cdf0e10cSrcweir rText.Erase();
3209cdf0e10cSrcweir return ePres;
3210cdf0e10cSrcweir
3211cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
3212cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
3213cdf0e10cSrcweir {
3214cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_FMTKEEP_FALSE;
3215cdf0e10cSrcweir
3216cdf0e10cSrcweir if ( GetValue() )
3217cdf0e10cSrcweir nId = RID_SVXITEMS_FMTKEEP_TRUE;
3218cdf0e10cSrcweir rText = EE_RESSTR(nId);
3219cdf0e10cSrcweir return ePres;
3220cdf0e10cSrcweir }
3221cdf0e10cSrcweir default: ;//prevent warning
3222cdf0e10cSrcweir }
3223cdf0e10cSrcweir #endif
3224cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3225cdf0e10cSrcweir }
3226cdf0e10cSrcweir
3227cdf0e10cSrcweir // class SvxLineItem ------------------------------------------------------
3228cdf0e10cSrcweir
SvxLineItem(const sal_uInt16 nId)3229cdf0e10cSrcweir SvxLineItem::SvxLineItem( const sal_uInt16 nId ) :
3230cdf0e10cSrcweir
3231cdf0e10cSrcweir SfxPoolItem ( nId ),
3232cdf0e10cSrcweir
3233cdf0e10cSrcweir pLine( NULL )
3234cdf0e10cSrcweir {
3235cdf0e10cSrcweir }
3236cdf0e10cSrcweir
3237cdf0e10cSrcweir // -----------------------------------------------------------------------
3238cdf0e10cSrcweir
SvxLineItem(const SvxLineItem & rCpy)3239cdf0e10cSrcweir SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) :
3240cdf0e10cSrcweir
3241cdf0e10cSrcweir SfxPoolItem ( rCpy )
3242cdf0e10cSrcweir {
3243cdf0e10cSrcweir pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : 0;
3244cdf0e10cSrcweir }
3245cdf0e10cSrcweir
3246cdf0e10cSrcweir
3247cdf0e10cSrcweir // -----------------------------------------------------------------------
3248cdf0e10cSrcweir
~SvxLineItem()3249cdf0e10cSrcweir SvxLineItem::~SvxLineItem()
3250cdf0e10cSrcweir {
3251cdf0e10cSrcweir delete pLine;
3252cdf0e10cSrcweir }
3253cdf0e10cSrcweir
3254cdf0e10cSrcweir // -----------------------------------------------------------------------
3255cdf0e10cSrcweir
operator =(const SvxLineItem & rLine)3256cdf0e10cSrcweir SvxLineItem& SvxLineItem::operator=( const SvxLineItem& rLine )
3257cdf0e10cSrcweir {
3258cdf0e10cSrcweir SetLine( rLine.GetLine() );
3259cdf0e10cSrcweir
3260cdf0e10cSrcweir return *this;
3261cdf0e10cSrcweir }
3262cdf0e10cSrcweir
3263cdf0e10cSrcweir // -----------------------------------------------------------------------
3264cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const3265cdf0e10cSrcweir int SvxLineItem::operator==( const SfxPoolItem& rAttr ) const
3266cdf0e10cSrcweir {
3267cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3268cdf0e10cSrcweir
3269cdf0e10cSrcweir return CmpBrdLn( pLine, ((SvxLineItem&)rAttr).GetLine() );
3270cdf0e10cSrcweir }
3271cdf0e10cSrcweir
3272cdf0e10cSrcweir // -----------------------------------------------------------------------
3273cdf0e10cSrcweir
Clone(SfxItemPool *) const3274cdf0e10cSrcweir SfxPoolItem* SvxLineItem::Clone( SfxItemPool* ) const
3275cdf0e10cSrcweir {
3276cdf0e10cSrcweir return new SvxLineItem( *this );
3277cdf0e10cSrcweir }
3278cdf0e10cSrcweir
QueryValue(uno::Any & rVal,sal_uInt8 nMemId) const3279cdf0e10cSrcweir sal_Bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const
3280cdf0e10cSrcweir {
3281cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3282cdf0e10cSrcweir nMemId &= ~CONVERT_TWIPS;
3283cdf0e10cSrcweir if ( nMemId == 0 )
3284cdf0e10cSrcweir {
3285cdf0e10cSrcweir rVal <<= uno::makeAny( SvxBoxItem::SvxLineToLine(pLine, bConvert) );
3286cdf0e10cSrcweir return sal_True;
3287cdf0e10cSrcweir }
3288cdf0e10cSrcweir else if ( pLine )
3289cdf0e10cSrcweir {
3290cdf0e10cSrcweir switch ( nMemId )
3291cdf0e10cSrcweir {
3292cdf0e10cSrcweir case MID_FG_COLOR: rVal <<= sal_Int32(pLine->GetColor().GetColor()); break;
3293cdf0e10cSrcweir case MID_OUTER_WIDTH: rVal <<= sal_Int32(pLine->GetOutWidth()); break;
3294cdf0e10cSrcweir case MID_INNER_WIDTH: rVal <<= sal_Int32(pLine->GetInWidth( )); break;
3295cdf0e10cSrcweir case MID_DISTANCE: rVal <<= sal_Int32(pLine->GetDistance()); break;
3296cdf0e10cSrcweir default:
3297cdf0e10cSrcweir DBG_ERROR( "Wrong MemberId" );
3298cdf0e10cSrcweir return sal_False;
3299cdf0e10cSrcweir }
3300cdf0e10cSrcweir }
3301cdf0e10cSrcweir
3302cdf0e10cSrcweir return sal_True;
3303cdf0e10cSrcweir }
3304cdf0e10cSrcweir
3305cdf0e10cSrcweir // -----------------------------------------------------------------------
3306cdf0e10cSrcweir
PutValue(const uno::Any & rVal,sal_uInt8 nMemId)3307cdf0e10cSrcweir sal_Bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId )
3308cdf0e10cSrcweir {
3309cdf0e10cSrcweir sal_Bool bConvert = 0!=(nMemId&CONVERT_TWIPS);
3310cdf0e10cSrcweir nMemId &= ~CONVERT_TWIPS;
3311cdf0e10cSrcweir sal_Int32 nVal = 0;
3312cdf0e10cSrcweir if ( nMemId == 0 )
3313cdf0e10cSrcweir {
3314cdf0e10cSrcweir table::BorderLine aLine;
3315cdf0e10cSrcweir if ( rVal >>= aLine )
3316cdf0e10cSrcweir {
3317cdf0e10cSrcweir if ( !pLine )
3318cdf0e10cSrcweir pLine = new SvxBorderLine;
3319cdf0e10cSrcweir if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) )
3320cdf0e10cSrcweir DELETEZ( pLine );
3321cdf0e10cSrcweir return sal_True;
3322cdf0e10cSrcweir }
3323cdf0e10cSrcweir return sal_False;
3324cdf0e10cSrcweir }
3325cdf0e10cSrcweir else if ( rVal >>= nVal )
3326cdf0e10cSrcweir {
3327cdf0e10cSrcweir if ( !pLine )
3328cdf0e10cSrcweir pLine = new SvxBorderLine;
3329cdf0e10cSrcweir
3330cdf0e10cSrcweir switch ( nMemId )
3331cdf0e10cSrcweir {
3332cdf0e10cSrcweir case MID_FG_COLOR: pLine->SetColor( Color(nVal) ); break;
3333cdf0e10cSrcweir case MID_OUTER_WIDTH: pLine->SetOutWidth((sal_uInt16)nVal); break;
3334cdf0e10cSrcweir case MID_INNER_WIDTH: pLine->SetInWidth((sal_uInt16)nVal); break;
3335cdf0e10cSrcweir case MID_DISTANCE: pLine->SetDistance((sal_uInt16)nVal); break;
3336cdf0e10cSrcweir default:
3337cdf0e10cSrcweir DBG_ERROR( "Wrong MemberId" );
3338cdf0e10cSrcweir return sal_False;
3339cdf0e10cSrcweir }
3340cdf0e10cSrcweir
3341cdf0e10cSrcweir return sal_True;
3342cdf0e10cSrcweir }
3343cdf0e10cSrcweir
3344cdf0e10cSrcweir return sal_False;
3345cdf0e10cSrcweir }
3346cdf0e10cSrcweir
3347cdf0e10cSrcweir //------------------------------------------------------------------------
3348cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit eCoreUnit,SfxMapUnit ePresUnit,XubString & rText,const IntlWrapper * pIntl) const3349cdf0e10cSrcweir SfxItemPresentation SvxLineItem::GetPresentation
3350cdf0e10cSrcweir (
3351cdf0e10cSrcweir SfxItemPresentation ePres,
3352cdf0e10cSrcweir SfxMapUnit eCoreUnit,
3353cdf0e10cSrcweir SfxMapUnit ePresUnit,
3354cdf0e10cSrcweir XubString& rText, const IntlWrapper *pIntl
3355cdf0e10cSrcweir ) const
3356cdf0e10cSrcweir {
3357cdf0e10cSrcweir #ifndef SVX_LIGHT
3358cdf0e10cSrcweir rText.Erase();
3359cdf0e10cSrcweir
3360cdf0e10cSrcweir switch ( ePres )
3361cdf0e10cSrcweir {
3362cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
3363cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3364cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
3365cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
3366cdf0e10cSrcweir {
3367cdf0e10cSrcweir if ( pLine )
3368cdf0e10cSrcweir rText = pLine->GetValueString( eCoreUnit, ePresUnit, pIntl,
3369cdf0e10cSrcweir (SFX_ITEM_PRESENTATION_COMPLETE == ePres) );
3370cdf0e10cSrcweir return ePres;
3371cdf0e10cSrcweir }
3372cdf0e10cSrcweir default: ;//prevent warning
3373cdf0e10cSrcweir }
3374cdf0e10cSrcweir #endif
3375cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3376cdf0e10cSrcweir }
3377cdf0e10cSrcweir
3378cdf0e10cSrcweir // -----------------------------------------------------------------------
3379cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const3380cdf0e10cSrcweir SvStream& SvxLineItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
3381cdf0e10cSrcweir {
3382cdf0e10cSrcweir if( pLine )
3383cdf0e10cSrcweir {
3384cdf0e10cSrcweir rStrm << pLine->GetColor()
3385cdf0e10cSrcweir << (short)pLine->GetOutWidth()
3386cdf0e10cSrcweir << (short)pLine->GetInWidth()
3387cdf0e10cSrcweir << (short)pLine->GetDistance();
3388cdf0e10cSrcweir }
3389cdf0e10cSrcweir else
3390cdf0e10cSrcweir rStrm << Color() << (short)0 << (short)0 << (short)0;
3391cdf0e10cSrcweir return rStrm;
3392cdf0e10cSrcweir }
3393cdf0e10cSrcweir
3394cdf0e10cSrcweir // -----------------------------------------------------------------------
3395cdf0e10cSrcweir
ScaleMetrics(long nMult,long nDiv)3396cdf0e10cSrcweir int SvxLineItem::ScaleMetrics( long nMult, long nDiv )
3397cdf0e10cSrcweir {
3398cdf0e10cSrcweir if ( pLine ) pLine->ScaleMetrics( nMult, nDiv );
3399cdf0e10cSrcweir return 1;
3400cdf0e10cSrcweir }
3401cdf0e10cSrcweir
3402cdf0e10cSrcweir // -----------------------------------------------------------------------
3403cdf0e10cSrcweir
HasMetrics() const3404cdf0e10cSrcweir int SvxLineItem::HasMetrics() const
3405cdf0e10cSrcweir {
3406cdf0e10cSrcweir return 1;
3407cdf0e10cSrcweir }
3408cdf0e10cSrcweir
3409cdf0e10cSrcweir // -----------------------------------------------------------------------
3410cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const3411cdf0e10cSrcweir SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const
3412cdf0e10cSrcweir {
3413cdf0e10cSrcweir SvxLineItem* _pLine = new SvxLineItem( Which() );
3414cdf0e10cSrcweir short nOutline, nInline, nDistance;
3415cdf0e10cSrcweir Color aColor;
3416cdf0e10cSrcweir
3417cdf0e10cSrcweir rStrm >> aColor >> nOutline >> nInline >> nDistance;
3418cdf0e10cSrcweir if( nOutline )
3419cdf0e10cSrcweir {
3420cdf0e10cSrcweir SvxBorderLine aLine( &aColor, nOutline, nInline, nDistance );
3421cdf0e10cSrcweir _pLine->SetLine( &aLine );
3422cdf0e10cSrcweir }
3423cdf0e10cSrcweir return _pLine;
3424cdf0e10cSrcweir }
3425cdf0e10cSrcweir
3426cdf0e10cSrcweir // -----------------------------------------------------------------------
3427cdf0e10cSrcweir
SetLine(const SvxBorderLine * pNew)3428cdf0e10cSrcweir void SvxLineItem::SetLine( const SvxBorderLine* pNew )
3429cdf0e10cSrcweir {
3430cdf0e10cSrcweir delete pLine;
3431cdf0e10cSrcweir pLine = pNew ? new SvxBorderLine( *pNew ) : 0;
3432cdf0e10cSrcweir }
3433cdf0e10cSrcweir
3434cdf0e10cSrcweir #ifdef _MSC_VER
3435cdf0e10cSrcweir #pragma optimize ( "", off )
3436cdf0e10cSrcweir #endif
3437cdf0e10cSrcweir
3438cdf0e10cSrcweir // class SvxBrushItem ----------------------------------------------------
3439cdf0e10cSrcweir
3440cdf0e10cSrcweir #define LOAD_GRAPHIC ((sal_uInt16)0x0001)
3441cdf0e10cSrcweir #define LOAD_LINK ((sal_uInt16)0x0002)
3442cdf0e10cSrcweir #define LOAD_FILTER ((sal_uInt16)0x0004)
3443cdf0e10cSrcweir
3444cdf0e10cSrcweir // class SvxBrushItem_Impl -----------------------------------------------
3445cdf0e10cSrcweir
3446cdf0e10cSrcweir class SvxBrushItem_Impl
3447cdf0e10cSrcweir {
3448cdf0e10cSrcweir public:
3449cdf0e10cSrcweir GraphicObject* pGraphicObject;
3450cdf0e10cSrcweir sal_Int8 nGraphicTransparency; //contains a percentage value which is
3451cdf0e10cSrcweir //copied to the GraphicObject when necessary
3452cdf0e10cSrcweir Link aDoneLink;
3453cdf0e10cSrcweir SvStream* pStream;
3454cdf0e10cSrcweir
SvxBrushItem_Impl(GraphicObject * p)3455cdf0e10cSrcweir SvxBrushItem_Impl( GraphicObject* p ) : pGraphicObject( p ), nGraphicTransparency(0), pStream(0) {}
3456cdf0e10cSrcweir };
3457cdf0e10cSrcweir
3458cdf0e10cSrcweir // -----------------------------------------------------------------------
3459cdf0e10cSrcweir
SetDoneLink(const Link & rLink)3460cdf0e10cSrcweir void SvxBrushItem::SetDoneLink( const Link& rLink )
3461cdf0e10cSrcweir {
3462cdf0e10cSrcweir pImpl->aDoneLink = rLink;
3463cdf0e10cSrcweir }
3464cdf0e10cSrcweir
3465cdf0e10cSrcweir // -----------------------------------------------------------------------
3466cdf0e10cSrcweir
SvxBrushItem(sal_uInt16 _nWhich)3467cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( sal_uInt16 _nWhich ) :
3468cdf0e10cSrcweir
3469cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3470cdf0e10cSrcweir
3471cdf0e10cSrcweir aColor ( COL_TRANSPARENT ),
3472cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( 0 ) ),
3473cdf0e10cSrcweir pStrLink ( NULL ),
3474cdf0e10cSrcweir pStrFilter ( NULL ),
3475cdf0e10cSrcweir eGraphicPos ( GPOS_NONE ),
3476cdf0e10cSrcweir bLoadAgain ( sal_True )
3477cdf0e10cSrcweir
3478cdf0e10cSrcweir {
3479cdf0e10cSrcweir }
3480cdf0e10cSrcweir
3481cdf0e10cSrcweir // -----------------------------------------------------------------------
3482cdf0e10cSrcweir
SvxBrushItem(const Color & rColor,sal_uInt16 _nWhich)3483cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( const Color& rColor, sal_uInt16 _nWhich) :
3484cdf0e10cSrcweir
3485cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3486cdf0e10cSrcweir
3487cdf0e10cSrcweir aColor ( rColor ),
3488cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( 0 ) ),
3489cdf0e10cSrcweir pStrLink ( NULL ),
3490cdf0e10cSrcweir pStrFilter ( NULL ),
3491cdf0e10cSrcweir eGraphicPos ( GPOS_NONE ),
3492cdf0e10cSrcweir bLoadAgain ( sal_True )
3493cdf0e10cSrcweir
3494cdf0e10cSrcweir {
3495cdf0e10cSrcweir }
3496cdf0e10cSrcweir
3497cdf0e10cSrcweir // -----------------------------------------------------------------------
3498cdf0e10cSrcweir
SvxBrushItem(const Graphic & rGraphic,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3499cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( const Graphic& rGraphic, SvxGraphicPosition ePos,
3500cdf0e10cSrcweir sal_uInt16 _nWhich ) :
3501cdf0e10cSrcweir
3502cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3503cdf0e10cSrcweir
3504cdf0e10cSrcweir aColor ( COL_TRANSPARENT ),
3505cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphic ) ) ),
3506cdf0e10cSrcweir pStrLink ( NULL ),
3507cdf0e10cSrcweir pStrFilter ( NULL ),
3508cdf0e10cSrcweir eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3509cdf0e10cSrcweir bLoadAgain ( sal_True )
3510cdf0e10cSrcweir
3511cdf0e10cSrcweir {
3512cdf0e10cSrcweir DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3513cdf0e10cSrcweir }
3514cdf0e10cSrcweir
3515cdf0e10cSrcweir // -----------------------------------------------------------------------
3516cdf0e10cSrcweir
SvxBrushItem(const GraphicObject & rGraphicObj,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3517cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( const GraphicObject& rGraphicObj,
3518cdf0e10cSrcweir SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3519cdf0e10cSrcweir
3520cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3521cdf0e10cSrcweir
3522cdf0e10cSrcweir aColor ( COL_TRANSPARENT ),
3523cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( new GraphicObject( rGraphicObj ) ) ),
3524cdf0e10cSrcweir pStrLink ( NULL ),
3525cdf0e10cSrcweir pStrFilter ( NULL ),
3526cdf0e10cSrcweir eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3527cdf0e10cSrcweir bLoadAgain ( sal_True )
3528cdf0e10cSrcweir
3529cdf0e10cSrcweir {
3530cdf0e10cSrcweir DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3531cdf0e10cSrcweir }
3532cdf0e10cSrcweir
3533cdf0e10cSrcweir // -----------------------------------------------------------------------
3534cdf0e10cSrcweir
SvxBrushItem(const String & rLink,const String & rFilter,SvxGraphicPosition ePos,sal_uInt16 _nWhich)3535cdf0e10cSrcweir SvxBrushItem::SvxBrushItem(
3536cdf0e10cSrcweir const String& rLink, const String& rFilter,
3537cdf0e10cSrcweir SvxGraphicPosition ePos, sal_uInt16 _nWhich ) :
3538cdf0e10cSrcweir
3539cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3540cdf0e10cSrcweir
3541cdf0e10cSrcweir aColor ( COL_TRANSPARENT ),
3542cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( NULL ) ),
3543cdf0e10cSrcweir pStrLink ( new String( rLink ) ),
3544cdf0e10cSrcweir pStrFilter ( new String( rFilter ) ),
3545cdf0e10cSrcweir eGraphicPos ( ( GPOS_NONE != ePos ) ? ePos : GPOS_MM ),
3546cdf0e10cSrcweir bLoadAgain ( sal_True )
3547cdf0e10cSrcweir
3548cdf0e10cSrcweir {
3549cdf0e10cSrcweir DBG_ASSERT( GPOS_NONE != ePos, "SvxBrushItem-Ctor with GPOS_NONE == ePos" );
3550cdf0e10cSrcweir }
3551cdf0e10cSrcweir
3552cdf0e10cSrcweir // -----------------------------------------------------------------------
3553cdf0e10cSrcweir
SvxBrushItem(SvStream & rStream,sal_uInt16 nVersion,sal_uInt16 _nWhich)3554cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( SvStream& rStream, sal_uInt16 nVersion,
3555cdf0e10cSrcweir sal_uInt16 _nWhich ) :
3556cdf0e10cSrcweir
3557cdf0e10cSrcweir SfxPoolItem( _nWhich ),
3558cdf0e10cSrcweir
3559cdf0e10cSrcweir aColor ( COL_TRANSPARENT ),
3560cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( NULL ) ),
3561cdf0e10cSrcweir pStrLink ( NULL ),
3562cdf0e10cSrcweir pStrFilter ( NULL ),
3563cdf0e10cSrcweir eGraphicPos ( GPOS_NONE )
3564cdf0e10cSrcweir
3565cdf0e10cSrcweir {
3566cdf0e10cSrcweir sal_Bool bTrans;
3567cdf0e10cSrcweir Color aTempColor;
3568cdf0e10cSrcweir Color aTempFillColor;
3569cdf0e10cSrcweir sal_Int8 nStyle;
3570cdf0e10cSrcweir
3571cdf0e10cSrcweir rStream >> bTrans;
3572cdf0e10cSrcweir rStream >> aTempColor;
3573cdf0e10cSrcweir rStream >> aTempFillColor;
3574cdf0e10cSrcweir rStream >> nStyle;
3575cdf0e10cSrcweir
3576cdf0e10cSrcweir switch ( nStyle )
3577cdf0e10cSrcweir {
3578cdf0e10cSrcweir case 8://BRUSH_25:
3579cdf0e10cSrcweir {
3580cdf0e10cSrcweir sal_uInt32 nRed = aTempColor.GetRed();
3581cdf0e10cSrcweir sal_uInt32 nGreen = aTempColor.GetGreen();
3582cdf0e10cSrcweir sal_uInt32 nBlue = aTempColor.GetBlue();
3583cdf0e10cSrcweir nRed += (sal_uInt32)(aTempFillColor.GetRed())*2;
3584cdf0e10cSrcweir nGreen += (sal_uInt32)(aTempFillColor.GetGreen())*2;
3585cdf0e10cSrcweir nBlue += (sal_uInt32)(aTempFillColor.GetBlue())*2;
3586cdf0e10cSrcweir aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3587cdf0e10cSrcweir }
3588cdf0e10cSrcweir break;
3589cdf0e10cSrcweir
3590cdf0e10cSrcweir case 9://BRUSH_50:
3591cdf0e10cSrcweir {
3592cdf0e10cSrcweir sal_uInt32 nRed = aTempColor.GetRed();
3593cdf0e10cSrcweir sal_uInt32 nGreen = aTempColor.GetGreen();
3594cdf0e10cSrcweir sal_uInt32 nBlue = aTempColor.GetBlue();
3595cdf0e10cSrcweir nRed += (sal_uInt32)(aTempFillColor.GetRed());
3596cdf0e10cSrcweir nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3597cdf0e10cSrcweir nBlue += (sal_uInt32)(aTempFillColor.GetBlue());
3598cdf0e10cSrcweir aColor = Color( (sal_Int8)(nRed/2), (sal_Int8)(nGreen/2), (sal_Int8)(nBlue/2) );
3599cdf0e10cSrcweir }
3600cdf0e10cSrcweir break;
3601cdf0e10cSrcweir
3602cdf0e10cSrcweir case 10://BRUSH_75:
3603cdf0e10cSrcweir {
3604cdf0e10cSrcweir sal_uInt32 nRed = aTempColor.GetRed()*2;
3605cdf0e10cSrcweir sal_uInt32 nGreen = aTempColor.GetGreen()*2;
3606cdf0e10cSrcweir sal_uInt32 nBlue = aTempColor.GetBlue()*2;
3607cdf0e10cSrcweir nRed += (sal_uInt32)(aTempFillColor.GetRed());
3608cdf0e10cSrcweir nGreen += (sal_uInt32)(aTempFillColor.GetGreen());
3609cdf0e10cSrcweir nBlue += (sal_uInt32)(aTempFillColor.GetBlue());
3610cdf0e10cSrcweir aColor = Color( (sal_Int8)(nRed/3), (sal_Int8)(nGreen/3), (sal_Int8)(nBlue/3) );
3611cdf0e10cSrcweir }
3612cdf0e10cSrcweir break;
3613cdf0e10cSrcweir
3614cdf0e10cSrcweir case 0://BRUSH_NULL:
3615cdf0e10cSrcweir aColor = Color( COL_TRANSPARENT );
3616cdf0e10cSrcweir break;
3617cdf0e10cSrcweir
3618cdf0e10cSrcweir default:
3619cdf0e10cSrcweir aColor = aTempColor;
3620cdf0e10cSrcweir }
3621cdf0e10cSrcweir
3622cdf0e10cSrcweir if ( nVersion >= BRUSH_GRAPHIC_VERSION )
3623cdf0e10cSrcweir {
3624cdf0e10cSrcweir sal_uInt16 nDoLoad = 0;
3625cdf0e10cSrcweir sal_Int8 nPos;
3626cdf0e10cSrcweir
3627cdf0e10cSrcweir rStream >> nDoLoad;
3628cdf0e10cSrcweir
3629cdf0e10cSrcweir if ( nDoLoad & LOAD_GRAPHIC )
3630cdf0e10cSrcweir {
3631cdf0e10cSrcweir Graphic aGraphic;
3632cdf0e10cSrcweir
3633cdf0e10cSrcweir rStream >> aGraphic;
3634cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject( aGraphic );
3635cdf0e10cSrcweir
3636cdf0e10cSrcweir if( SVSTREAM_FILEFORMAT_ERROR == rStream.GetError() )
3637cdf0e10cSrcweir {
3638cdf0e10cSrcweir rStream.ResetError();
3639cdf0e10cSrcweir rStream.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT|
3640cdf0e10cSrcweir ERRCODE_WARNING_MASK );
3641cdf0e10cSrcweir }
3642cdf0e10cSrcweir }
3643cdf0e10cSrcweir
3644cdf0e10cSrcweir if ( nDoLoad & LOAD_LINK )
3645cdf0e10cSrcweir {
3646cdf0e10cSrcweir String aRel;
3647cdf0e10cSrcweir // UNICODE: rStream >> aRel;
3648cdf0e10cSrcweir rStream.ReadByteString(aRel);
3649cdf0e10cSrcweir
3650cdf0e10cSrcweir // TODO/MBA: how can we get a BaseURL here?!
3651cdf0e10cSrcweir DBG_ERROR("No BaseURL!");
3652cdf0e10cSrcweir String aAbs = INetURLObject::GetAbsURL( String(), aRel );
3653cdf0e10cSrcweir DBG_ASSERT( aAbs.Len(), "Invalid URL!" );
3654cdf0e10cSrcweir pStrLink = new String( aAbs );
3655cdf0e10cSrcweir }
3656cdf0e10cSrcweir
3657cdf0e10cSrcweir if ( nDoLoad & LOAD_FILTER )
3658cdf0e10cSrcweir {
3659cdf0e10cSrcweir pStrFilter = new String;
3660cdf0e10cSrcweir // UNICODE: rStream >> *pStrFilter;
3661cdf0e10cSrcweir rStream.ReadByteString(*pStrFilter);
3662cdf0e10cSrcweir }
3663cdf0e10cSrcweir
3664cdf0e10cSrcweir rStream >> nPos;
3665cdf0e10cSrcweir
3666cdf0e10cSrcweir eGraphicPos = (SvxGraphicPosition)nPos;
3667cdf0e10cSrcweir }
3668cdf0e10cSrcweir }
3669cdf0e10cSrcweir
3670cdf0e10cSrcweir // -----------------------------------------------------------------------
3671cdf0e10cSrcweir
SvxBrushItem(const SvxBrushItem & rItem)3672cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( const SvxBrushItem& rItem ) :
3673cdf0e10cSrcweir
3674cdf0e10cSrcweir SfxPoolItem( rItem.Which() ),
3675cdf0e10cSrcweir
3676cdf0e10cSrcweir pImpl ( new SvxBrushItem_Impl( NULL ) ),
3677cdf0e10cSrcweir pStrLink ( NULL ),
3678cdf0e10cSrcweir pStrFilter ( NULL ),
3679cdf0e10cSrcweir eGraphicPos ( GPOS_NONE ),
3680cdf0e10cSrcweir bLoadAgain ( sal_True )
3681cdf0e10cSrcweir
3682cdf0e10cSrcweir {
3683cdf0e10cSrcweir *this = rItem;
3684cdf0e10cSrcweir }
3685cdf0e10cSrcweir
3686cdf0e10cSrcweir // -----------------------------------------------------------------------
3687cdf0e10cSrcweir
~SvxBrushItem()3688cdf0e10cSrcweir SvxBrushItem::~SvxBrushItem()
3689cdf0e10cSrcweir {
3690cdf0e10cSrcweir delete pImpl->pGraphicObject;
3691cdf0e10cSrcweir delete pImpl;
3692cdf0e10cSrcweir delete pStrLink;
3693cdf0e10cSrcweir delete pStrFilter;
3694cdf0e10cSrcweir }
3695cdf0e10cSrcweir
3696cdf0e10cSrcweir // -----------------------------------------------------------------------
3697cdf0e10cSrcweir
GetVersion(sal_uInt16) const3698cdf0e10cSrcweir sal_uInt16 SvxBrushItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
3699cdf0e10cSrcweir {
3700cdf0e10cSrcweir return BRUSH_GRAPHIC_VERSION;
3701cdf0e10cSrcweir }
3702cdf0e10cSrcweir
3703cdf0e10cSrcweir // -----------------------------------------------------------------------
lcl_PercentToTransparency(long nPercent)3704cdf0e10cSrcweir inline sal_Int8 lcl_PercentToTransparency(long nPercent)
3705cdf0e10cSrcweir {
3706cdf0e10cSrcweir //0xff must not be returned!
3707cdf0e10cSrcweir return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0);
3708cdf0e10cSrcweir }
lcl_TransparencyToPercent(sal_Int32 nTrans)3709cdf0e10cSrcweir inline sal_Int8 lcl_TransparencyToPercent(sal_Int32 nTrans)
3710cdf0e10cSrcweir {
3711cdf0e10cSrcweir return (sal_Int8)((nTrans * 100 + 127) / 254);
3712cdf0e10cSrcweir }
3713cdf0e10cSrcweir
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const3714cdf0e10cSrcweir sal_Bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
3715cdf0e10cSrcweir {
3716cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3717cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
3718cdf0e10cSrcweir switch( nMemberId)
3719cdf0e10cSrcweir {
3720cdf0e10cSrcweir case MID_BACK_COLOR:
3721cdf0e10cSrcweir rVal <<= (sal_Int32)( aColor.GetColor() );
3722cdf0e10cSrcweir break;
3723cdf0e10cSrcweir case MID_BACK_COLOR_R_G_B:
3724cdf0e10cSrcweir rVal <<= (sal_Int32)( aColor.GetRGBColor() );
3725cdf0e10cSrcweir break;
3726cdf0e10cSrcweir case MID_BACK_COLOR_TRANSPARENCY:
3727cdf0e10cSrcweir rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency());
3728cdf0e10cSrcweir break;
3729cdf0e10cSrcweir case MID_GRAPHIC_POSITION:
3730cdf0e10cSrcweir rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos;
3731cdf0e10cSrcweir break;
3732cdf0e10cSrcweir
3733cdf0e10cSrcweir case MID_GRAPHIC:
3734cdf0e10cSrcweir DBG_ERRORFILE( "not implemented" );
3735cdf0e10cSrcweir break;
3736cdf0e10cSrcweir
3737cdf0e10cSrcweir case MID_GRAPHIC_TRANSPARENT:
3738cdf0e10cSrcweir rVal = Bool2Any( aColor.GetTransparency() == 0xff );
3739cdf0e10cSrcweir break;
3740cdf0e10cSrcweir
3741cdf0e10cSrcweir case MID_GRAPHIC_URL:
3742cdf0e10cSrcweir {
3743cdf0e10cSrcweir OUString sLink;
3744cdf0e10cSrcweir if ( pStrLink )
3745cdf0e10cSrcweir sLink = *pStrLink;
3746cdf0e10cSrcweir else if( pImpl->pGraphicObject )
3747cdf0e10cSrcweir {
3748cdf0e10cSrcweir OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
3749cdf0e10cSrcweir String sId( pImpl->pGraphicObject->GetUniqueID(),
3750cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US );
3751cdf0e10cSrcweir sLink = sPrefix;
3752cdf0e10cSrcweir sLink += OUString(sId);
3753cdf0e10cSrcweir }
3754cdf0e10cSrcweir rVal <<= sLink;
3755cdf0e10cSrcweir }
3756cdf0e10cSrcweir break;
3757cdf0e10cSrcweir
3758cdf0e10cSrcweir case MID_GRAPHIC_FILTER:
3759cdf0e10cSrcweir {
3760cdf0e10cSrcweir OUString sFilter;
3761cdf0e10cSrcweir if ( pStrFilter )
3762cdf0e10cSrcweir sFilter = *pStrFilter;
3763cdf0e10cSrcweir rVal <<= sFilter;
3764cdf0e10cSrcweir }
3765cdf0e10cSrcweir break;
3766cdf0e10cSrcweir case MID_GRAPHIC_TRANSPARENCY :
3767cdf0e10cSrcweir rVal <<= pImpl->nGraphicTransparency;
3768cdf0e10cSrcweir break;
3769cdf0e10cSrcweir }
3770cdf0e10cSrcweir
3771cdf0e10cSrcweir return sal_True;
3772cdf0e10cSrcweir }
3773cdf0e10cSrcweir
3774cdf0e10cSrcweir // -----------------------------------------------------------------------
3775cdf0e10cSrcweir
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)3776cdf0e10cSrcweir sal_Bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
3777cdf0e10cSrcweir {
3778cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
3779cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS;
3780cdf0e10cSrcweir switch( nMemberId)
3781cdf0e10cSrcweir {
3782cdf0e10cSrcweir case MID_BACK_COLOR:
3783cdf0e10cSrcweir case MID_BACK_COLOR_R_G_B:
3784cdf0e10cSrcweir {
3785cdf0e10cSrcweir sal_Int32 nCol = 0;
3786cdf0e10cSrcweir if ( !( rVal >>= nCol ) )
3787cdf0e10cSrcweir return sal_False;
3788cdf0e10cSrcweir if(MID_BACK_COLOR_R_G_B == nMemberId)
3789cdf0e10cSrcweir {
3790cdf0e10cSrcweir nCol = COLORDATA_RGB( nCol );
3791cdf0e10cSrcweir nCol += aColor.GetColor() & 0xff000000;
3792cdf0e10cSrcweir }
3793cdf0e10cSrcweir aColor = Color( nCol );
3794cdf0e10cSrcweir }
3795cdf0e10cSrcweir break;
3796cdf0e10cSrcweir case MID_BACK_COLOR_TRANSPARENCY:
3797cdf0e10cSrcweir {
3798cdf0e10cSrcweir sal_Int32 nTrans = 0;
3799cdf0e10cSrcweir if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 )
3800cdf0e10cSrcweir return sal_False;
3801cdf0e10cSrcweir aColor.SetTransparency(lcl_PercentToTransparency(nTrans));
3802cdf0e10cSrcweir }
3803cdf0e10cSrcweir break;
3804cdf0e10cSrcweir
3805cdf0e10cSrcweir case MID_GRAPHIC_POSITION:
3806cdf0e10cSrcweir {
3807cdf0e10cSrcweir style::GraphicLocation eLocation;
3808cdf0e10cSrcweir if ( !( rVal>>=eLocation ) )
3809cdf0e10cSrcweir {
3810cdf0e10cSrcweir sal_Int32 nValue = 0;
3811cdf0e10cSrcweir if ( !( rVal >>= nValue ) )
3812cdf0e10cSrcweir return sal_False;
3813cdf0e10cSrcweir eLocation = (style::GraphicLocation)nValue;
3814cdf0e10cSrcweir }
3815cdf0e10cSrcweir SetGraphicPos( (SvxGraphicPosition)(sal_uInt16)eLocation );
3816cdf0e10cSrcweir }
3817cdf0e10cSrcweir break;
3818cdf0e10cSrcweir
3819cdf0e10cSrcweir case MID_GRAPHIC:
3820cdf0e10cSrcweir DBG_ERRORFILE( "not implemented" );
3821cdf0e10cSrcweir break;
3822cdf0e10cSrcweir
3823cdf0e10cSrcweir case MID_GRAPHIC_TRANSPARENT:
3824cdf0e10cSrcweir aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
3825cdf0e10cSrcweir break;
3826cdf0e10cSrcweir
3827cdf0e10cSrcweir case MID_GRAPHIC_URL:
3828cdf0e10cSrcweir {
3829cdf0e10cSrcweir if ( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3830cdf0e10cSrcweir {
3831cdf0e10cSrcweir OUString sLink;
3832cdf0e10cSrcweir rVal >>= sLink;
3833cdf0e10cSrcweir if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX,
3834cdf0e10cSrcweir sizeof(UNO_NAME_GRAPHOBJ_URLPKGPREFIX)-1 ) )
3835cdf0e10cSrcweir {
3836cdf0e10cSrcweir DBG_ERROR( "package urls aren't implemented" );
3837cdf0e10cSrcweir }
3838cdf0e10cSrcweir else if( 0 == sLink.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX,
3839cdf0e10cSrcweir sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1 ) )
3840cdf0e10cSrcweir {
3841cdf0e10cSrcweir DELETEZ( pStrLink );
3842cdf0e10cSrcweir String sTmp( sLink );
3843cdf0e10cSrcweir ByteString sId( sTmp.Copy(
3844cdf0e10cSrcweir sizeof(UNO_NAME_GRAPHOBJ_URLPREFIX)-1),
3845cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US );
3846cdf0e10cSrcweir GraphicObject *pOldGrfObj = pImpl->pGraphicObject;
3847cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject( sId );
3848cdf0e10cSrcweir ApplyGraphicTransparency_Impl();
3849cdf0e10cSrcweir delete pOldGrfObj;
3850cdf0e10cSrcweir }
3851cdf0e10cSrcweir else
3852cdf0e10cSrcweir {
3853cdf0e10cSrcweir SetGraphicLink(sLink);
3854cdf0e10cSrcweir }
3855cdf0e10cSrcweir if ( sLink.getLength() && eGraphicPos == GPOS_NONE )
3856cdf0e10cSrcweir eGraphicPos = GPOS_MM;
3857cdf0e10cSrcweir else if( !sLink.getLength() )
3858cdf0e10cSrcweir eGraphicPos = GPOS_NONE;
3859cdf0e10cSrcweir }
3860cdf0e10cSrcweir }
3861cdf0e10cSrcweir break;
3862cdf0e10cSrcweir
3863cdf0e10cSrcweir case MID_GRAPHIC_FILTER:
3864cdf0e10cSrcweir {
3865cdf0e10cSrcweir if( rVal.getValueType() == ::getCppuType( (OUString*)0 ) )
3866cdf0e10cSrcweir {
3867cdf0e10cSrcweir OUString sLink;
3868cdf0e10cSrcweir rVal >>= sLink;
3869cdf0e10cSrcweir SetGraphicFilter( sLink );
3870cdf0e10cSrcweir }
3871cdf0e10cSrcweir }
3872cdf0e10cSrcweir break;
3873cdf0e10cSrcweir case MID_GRAPHIC_TRANSPARENCY :
3874cdf0e10cSrcweir {
3875cdf0e10cSrcweir sal_Int32 nTmp = 0;
3876cdf0e10cSrcweir rVal >>= nTmp;
3877cdf0e10cSrcweir if(nTmp >= 0 && nTmp <= 100)
3878cdf0e10cSrcweir {
3879cdf0e10cSrcweir pImpl->nGraphicTransparency = sal_Int8(nTmp);
3880cdf0e10cSrcweir if(pImpl->pGraphicObject)
3881cdf0e10cSrcweir ApplyGraphicTransparency_Impl();
3882cdf0e10cSrcweir }
3883cdf0e10cSrcweir }
3884cdf0e10cSrcweir break;
3885cdf0e10cSrcweir }
3886cdf0e10cSrcweir
3887cdf0e10cSrcweir return sal_True;
3888cdf0e10cSrcweir }
3889cdf0e10cSrcweir
3890cdf0e10cSrcweir // -----------------------------------------------------------------------
3891cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const3892cdf0e10cSrcweir SfxItemPresentation SvxBrushItem::GetPresentation
3893cdf0e10cSrcweir (
3894cdf0e10cSrcweir SfxItemPresentation ePres,
3895cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
3896cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
3897cdf0e10cSrcweir XubString& rText, const IntlWrapper *
3898cdf0e10cSrcweir ) const
3899cdf0e10cSrcweir {
3900cdf0e10cSrcweir switch ( ePres )
3901cdf0e10cSrcweir {
3902cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
3903cdf0e10cSrcweir rText.Erase();
3904cdf0e10cSrcweir return ePres;
3905cdf0e10cSrcweir
3906cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
3907cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
3908cdf0e10cSrcweir {
3909cdf0e10cSrcweir if ( GPOS_NONE == eGraphicPos )
3910cdf0e10cSrcweir {
3911cdf0e10cSrcweir rText = ::GetColorString( aColor );
3912cdf0e10cSrcweir rText += cpDelim;
3913cdf0e10cSrcweir sal_uInt16 nId = RID_SVXITEMS_TRANSPARENT_FALSE;
3914cdf0e10cSrcweir
3915cdf0e10cSrcweir if ( aColor.GetTransparency() )
3916cdf0e10cSrcweir nId = RID_SVXITEMS_TRANSPARENT_TRUE;
3917cdf0e10cSrcweir rText += EE_RESSTR(nId);
3918cdf0e10cSrcweir }
3919cdf0e10cSrcweir else
3920cdf0e10cSrcweir {
3921cdf0e10cSrcweir rText = EE_RESSTR(RID_SVXITEMS_GRAPHIC);
3922cdf0e10cSrcweir }
3923cdf0e10cSrcweir
3924cdf0e10cSrcweir return ePres;
3925cdf0e10cSrcweir }
3926cdf0e10cSrcweir default: ;//prevent warning
3927cdf0e10cSrcweir }
3928cdf0e10cSrcweir
3929cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE;
3930cdf0e10cSrcweir }
3931cdf0e10cSrcweir
3932cdf0e10cSrcweir // -----------------------------------------------------------------------
3933cdf0e10cSrcweir
operator =(const SvxBrushItem & rItem)3934cdf0e10cSrcweir SvxBrushItem& SvxBrushItem::operator=( const SvxBrushItem& rItem )
3935cdf0e10cSrcweir {
3936cdf0e10cSrcweir aColor = rItem.aColor;
3937cdf0e10cSrcweir eGraphicPos = rItem.eGraphicPos;
3938cdf0e10cSrcweir
3939cdf0e10cSrcweir DELETEZ( pImpl->pGraphicObject );
3940cdf0e10cSrcweir DELETEZ( pStrLink );
3941cdf0e10cSrcweir DELETEZ( pStrFilter );
3942cdf0e10cSrcweir
3943cdf0e10cSrcweir if ( GPOS_NONE != eGraphicPos )
3944cdf0e10cSrcweir {
3945cdf0e10cSrcweir if ( rItem.pStrLink )
3946cdf0e10cSrcweir pStrLink = new String( *rItem.pStrLink );
3947cdf0e10cSrcweir if ( rItem.pStrFilter )
3948cdf0e10cSrcweir pStrFilter = new String( *rItem.pStrFilter );
3949cdf0e10cSrcweir if ( rItem.pImpl->pGraphicObject )
3950cdf0e10cSrcweir {
3951cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject( *rItem.pImpl->pGraphicObject );
3952cdf0e10cSrcweir }
3953cdf0e10cSrcweir }
3954cdf0e10cSrcweir pImpl->nGraphicTransparency = rItem.pImpl->nGraphicTransparency;
3955cdf0e10cSrcweir return *this;
3956cdf0e10cSrcweir }
3957cdf0e10cSrcweir
3958cdf0e10cSrcweir // -----------------------------------------------------------------------
3959cdf0e10cSrcweir
operator ==(const SfxPoolItem & rAttr) const3960cdf0e10cSrcweir int SvxBrushItem::operator==( const SfxPoolItem& rAttr ) const
3961cdf0e10cSrcweir {
3962cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
3963cdf0e10cSrcweir
3964cdf0e10cSrcweir SvxBrushItem& rCmp = (SvxBrushItem&)rAttr;
3965cdf0e10cSrcweir sal_Bool bEqual = ( aColor == rCmp.aColor && eGraphicPos == rCmp.eGraphicPos &&
3966cdf0e10cSrcweir pImpl->nGraphicTransparency == rCmp.pImpl->nGraphicTransparency);
3967cdf0e10cSrcweir
3968cdf0e10cSrcweir if ( bEqual )
3969cdf0e10cSrcweir {
3970cdf0e10cSrcweir if ( GPOS_NONE != eGraphicPos )
3971cdf0e10cSrcweir {
3972cdf0e10cSrcweir if ( !rCmp.pStrLink )
3973cdf0e10cSrcweir bEqual = !pStrLink;
3974cdf0e10cSrcweir else
3975cdf0e10cSrcweir bEqual = pStrLink && ( *pStrLink == *rCmp.pStrLink );
3976cdf0e10cSrcweir
3977cdf0e10cSrcweir if ( bEqual )
3978cdf0e10cSrcweir {
3979cdf0e10cSrcweir if ( !rCmp.pStrFilter )
3980cdf0e10cSrcweir bEqual = !pStrFilter;
3981cdf0e10cSrcweir else
3982cdf0e10cSrcweir bEqual = pStrFilter && ( *pStrFilter == *rCmp.pStrFilter );
3983cdf0e10cSrcweir }
3984cdf0e10cSrcweir
3985cdf0e10cSrcweir if ( bEqual && !rCmp.pStrLink )
3986cdf0e10cSrcweir {
3987cdf0e10cSrcweir if ( !rCmp.pImpl->pGraphicObject )
3988cdf0e10cSrcweir bEqual = !pImpl->pGraphicObject;
3989cdf0e10cSrcweir else
3990cdf0e10cSrcweir bEqual = pImpl->pGraphicObject &&
3991cdf0e10cSrcweir ( *pImpl->pGraphicObject == *rCmp.pImpl->pGraphicObject );
3992cdf0e10cSrcweir }
3993cdf0e10cSrcweir }
3994cdf0e10cSrcweir }
3995cdf0e10cSrcweir
3996cdf0e10cSrcweir return bEqual;
3997cdf0e10cSrcweir }
3998cdf0e10cSrcweir
3999cdf0e10cSrcweir // -----------------------------------------------------------------------
4000cdf0e10cSrcweir
Clone(SfxItemPool *) const4001cdf0e10cSrcweir SfxPoolItem* SvxBrushItem::Clone( SfxItemPool* ) const
4002cdf0e10cSrcweir {
4003cdf0e10cSrcweir return new SvxBrushItem( *this );
4004cdf0e10cSrcweir }
4005cdf0e10cSrcweir
4006cdf0e10cSrcweir // -----------------------------------------------------------------------
4007cdf0e10cSrcweir
Create(SvStream & rStream,sal_uInt16 nVersion) const4008cdf0e10cSrcweir SfxPoolItem* SvxBrushItem::Create( SvStream& rStream, sal_uInt16 nVersion ) const
4009cdf0e10cSrcweir {
4010cdf0e10cSrcweir return new SvxBrushItem( rStream, nVersion, Which() );
4011cdf0e10cSrcweir }
4012cdf0e10cSrcweir
4013cdf0e10cSrcweir // -----------------------------------------------------------------------
4014cdf0e10cSrcweir
Store(SvStream & rStream,sal_uInt16) const4015cdf0e10cSrcweir SvStream& SvxBrushItem::Store( SvStream& rStream , sal_uInt16 /*nItemVersion*/ ) const
4016cdf0e10cSrcweir {
4017cdf0e10cSrcweir rStream << (sal_Bool)sal_False;
4018cdf0e10cSrcweir rStream << aColor;
4019cdf0e10cSrcweir rStream << aColor;
4020cdf0e10cSrcweir rStream << (sal_Int8)(aColor.GetTransparency() > 0 ? 0 : 1); //BRUSH_NULL : BRUSH_SOLID
4021cdf0e10cSrcweir
4022cdf0e10cSrcweir sal_uInt16 nDoLoad = 0;
4023cdf0e10cSrcweir
4024cdf0e10cSrcweir if ( pImpl->pGraphicObject && !pStrLink )
4025cdf0e10cSrcweir nDoLoad |= LOAD_GRAPHIC;
4026cdf0e10cSrcweir if ( pStrLink )
4027cdf0e10cSrcweir nDoLoad |= LOAD_LINK;
4028cdf0e10cSrcweir if ( pStrFilter )
4029cdf0e10cSrcweir nDoLoad |= LOAD_FILTER;
4030cdf0e10cSrcweir rStream << nDoLoad;
4031cdf0e10cSrcweir
4032cdf0e10cSrcweir if ( pImpl->pGraphicObject && !pStrLink )
4033cdf0e10cSrcweir rStream << pImpl->pGraphicObject->GetGraphic();
4034cdf0e10cSrcweir if ( pStrLink )
4035cdf0e10cSrcweir {
4036cdf0e10cSrcweir DBG_ERROR("No BaseURL!");
4037cdf0e10cSrcweir // TODO/MBA: how to get a BaseURL?!
4038cdf0e10cSrcweir String aRel = INetURLObject::GetRelURL( String(), *pStrLink );
4039cdf0e10cSrcweir // UNICODE: rStream << aRel;
4040cdf0e10cSrcweir rStream.WriteByteString(aRel);
4041cdf0e10cSrcweir }
4042cdf0e10cSrcweir if ( pStrFilter )
4043cdf0e10cSrcweir {
4044cdf0e10cSrcweir // UNICODE: rStream << *pStrFilter;
4045cdf0e10cSrcweir rStream.WriteByteString(*pStrFilter);
4046cdf0e10cSrcweir }
4047cdf0e10cSrcweir rStream << (sal_Int8)eGraphicPos;
4048cdf0e10cSrcweir return rStream;
4049cdf0e10cSrcweir }
4050cdf0e10cSrcweir
4051cdf0e10cSrcweir // -----------------------------------------------------------------------
4052cdf0e10cSrcweir // const wegcasten, da const als logisches const zu verstehen ist
4053cdf0e10cSrcweir // wenn GetGraphic() gerufen wird, soll sich das Item darum kuemmern,
4054cdf0e10cSrcweir // eine gelinkte Grafik zu holen.
4055cdf0e10cSrcweir // -----------------------------------------------------------------------
4056cdf0e10cSrcweir
PurgeGraphic() const4057cdf0e10cSrcweir void SvxBrushItem::PurgeGraphic() const
4058cdf0e10cSrcweir {
4059cdf0e10cSrcweir PurgeMedium();
4060cdf0e10cSrcweir DELETEZ( pImpl->pGraphicObject );
4061cdf0e10cSrcweir ((SvxBrushItem*)this)->bLoadAgain = sal_True;
4062cdf0e10cSrcweir }
4063cdf0e10cSrcweir
4064cdf0e10cSrcweir // -----------------------------------------------------------------------
4065cdf0e10cSrcweir
PurgeMedium() const4066cdf0e10cSrcweir void SvxBrushItem::PurgeMedium() const
4067cdf0e10cSrcweir {
4068cdf0e10cSrcweir DELETEZ( pImpl->pStream );
4069cdf0e10cSrcweir }
4070cdf0e10cSrcweir
4071cdf0e10cSrcweir // -----------------------------------------------------------------------
GetGraphicObject() const4072cdf0e10cSrcweir const GraphicObject* SvxBrushItem::GetGraphicObject() const
4073cdf0e10cSrcweir {
4074cdf0e10cSrcweir if ( bLoadAgain && pStrLink && !pImpl->pGraphicObject )
4075cdf0e10cSrcweir // wenn Grafik schon geladen, als Cache benutzen
4076cdf0e10cSrcweir {
4077cdf0e10cSrcweir //JP 29.6.2001: only with "valid" names - empty names now allowed
4078cdf0e10cSrcweir if( pStrLink->Len() )
4079cdf0e10cSrcweir {
4080cdf0e10cSrcweir // currently we don't have asynchronous processing
4081cdf0e10cSrcweir /* if( pImpl->aDoneLink.IsSet() )
4082cdf0e10cSrcweir {
4083cdf0e10cSrcweir // Auf besonderen Wunsch des Writers wird der synchrone und der
4084cdf0e10cSrcweir // asynchrone Fall was die Benachrichtigung angeht unterschiedlich
4085cdf0e10cSrcweir // behandelt. Der Callback erfolgt nur bei asynchronem Eintreffen
4086cdf0e10cSrcweir // der Daten
4087cdf0e10cSrcweir
4088cdf0e10cSrcweir Link aTmp = pImpl->aDoneLink;
4089cdf0e10cSrcweir pImpl->aDoneLink = Link();
4090cdf0e10cSrcweir pImpl->xMedium->DownLoad(
4091cdf0e10cSrcweir STATIC_LINK( this, SvxBrushItem, DoneHdl_Impl ) );
4092cdf0e10cSrcweir pImpl->aDoneLink = aTmp;
4093cdf0e10cSrcweir } */
4094cdf0e10cSrcweir
4095cdf0e10cSrcweir pImpl->pStream = utl::UcbStreamHelper::CreateStream( *pStrLink, STREAM_STD_READ );
4096cdf0e10cSrcweir if( pImpl->pStream && !pImpl->pStream->GetError() )
4097cdf0e10cSrcweir {
4098cdf0e10cSrcweir Graphic aGraphic;
4099cdf0e10cSrcweir int nRes;
4100cdf0e10cSrcweir pImpl->pStream->Seek( STREAM_SEEK_TO_BEGIN );
4101cdf0e10cSrcweir nRes = GraphicFilter::GetGraphicFilter()->
4102cdf0e10cSrcweir ImportGraphic( aGraphic, *pStrLink, *pImpl->pStream,
4103cdf0e10cSrcweir GRFILTER_FORMAT_DONTKNOW, NULL, GRFILTER_I_FLAGS_DONT_SET_LOGSIZE_FOR_JPEG );
4104cdf0e10cSrcweir
4105cdf0e10cSrcweir if( nRes != GRFILTER_OK )
4106cdf0e10cSrcweir {
4107cdf0e10cSrcweir const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
4108cdf0e10cSrcweir }
4109cdf0e10cSrcweir else
4110cdf0e10cSrcweir {
4111cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject;
4112cdf0e10cSrcweir pImpl->pGraphicObject->SetGraphic( aGraphic );
4113cdf0e10cSrcweir const_cast < SvxBrushItem*> (this)->ApplyGraphicTransparency_Impl();
4114cdf0e10cSrcweir }
4115cdf0e10cSrcweir }
4116cdf0e10cSrcweir else
4117cdf0e10cSrcweir {
4118cdf0e10cSrcweir const_cast < SvxBrushItem*> (this)->bLoadAgain = sal_False;
4119cdf0e10cSrcweir }
4120cdf0e10cSrcweir
4121cdf0e10cSrcweir // currently we don't have asynchronous processing
4122cdf0e10cSrcweir // pThis->pImpl->aDoneLink.Call( pThis );
4123cdf0e10cSrcweir }
4124cdf0e10cSrcweir }
4125cdf0e10cSrcweir
4126cdf0e10cSrcweir return pImpl->pGraphicObject;
4127cdf0e10cSrcweir }
4128cdf0e10cSrcweir
4129cdf0e10cSrcweir // -----------------------------------------------------------------------
4130cdf0e10cSrcweir
GetGraphic() const4131cdf0e10cSrcweir const Graphic* SvxBrushItem::GetGraphic() const
4132cdf0e10cSrcweir {
4133cdf0e10cSrcweir const GraphicObject* pGrafObj = GetGraphicObject();
4134cdf0e10cSrcweir return( pGrafObj ? &( pGrafObj->GetGraphic() ) : NULL );
4135cdf0e10cSrcweir }
4136cdf0e10cSrcweir
4137cdf0e10cSrcweir // -----------------------------------------------------------------------
4138cdf0e10cSrcweir
SetGraphicPos(SvxGraphicPosition eNew)4139cdf0e10cSrcweir void SvxBrushItem::SetGraphicPos( SvxGraphicPosition eNew )
4140cdf0e10cSrcweir {
4141cdf0e10cSrcweir eGraphicPos = eNew;
4142cdf0e10cSrcweir
4143cdf0e10cSrcweir if ( GPOS_NONE == eGraphicPos )
4144cdf0e10cSrcweir {
4145cdf0e10cSrcweir DELETEZ( pImpl->pGraphicObject );
4146cdf0e10cSrcweir DELETEZ( pStrLink );
4147cdf0e10cSrcweir DELETEZ( pStrFilter );
4148cdf0e10cSrcweir }
4149cdf0e10cSrcweir else
4150cdf0e10cSrcweir {
4151cdf0e10cSrcweir if ( !pImpl->pGraphicObject && !pStrLink )
4152cdf0e10cSrcweir {
4153cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject; // dummy anlegen
4154cdf0e10cSrcweir }
4155cdf0e10cSrcweir }
4156cdf0e10cSrcweir }
4157cdf0e10cSrcweir
4158cdf0e10cSrcweir // -----------------------------------------------------------------------
4159cdf0e10cSrcweir
SetGraphic(const Graphic & rNew)4160cdf0e10cSrcweir void SvxBrushItem::SetGraphic( const Graphic& rNew )
4161cdf0e10cSrcweir {
4162cdf0e10cSrcweir if ( !pStrLink )
4163cdf0e10cSrcweir {
4164cdf0e10cSrcweir if ( pImpl->pGraphicObject )
4165cdf0e10cSrcweir pImpl->pGraphicObject->SetGraphic( rNew );
4166cdf0e10cSrcweir else
4167cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject( rNew );
4168cdf0e10cSrcweir
4169cdf0e10cSrcweir ApplyGraphicTransparency_Impl();
4170cdf0e10cSrcweir
4171cdf0e10cSrcweir if ( GPOS_NONE == eGraphicPos )
4172cdf0e10cSrcweir eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4173cdf0e10cSrcweir }
4174cdf0e10cSrcweir else
4175cdf0e10cSrcweir {
4176cdf0e10cSrcweir DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4177cdf0e10cSrcweir }
4178cdf0e10cSrcweir }
4179cdf0e10cSrcweir
4180cdf0e10cSrcweir // -----------------------------------------------------------------------
4181cdf0e10cSrcweir
SetGraphicObject(const GraphicObject & rNewObj)4182cdf0e10cSrcweir void SvxBrushItem::SetGraphicObject( const GraphicObject& rNewObj )
4183cdf0e10cSrcweir {
4184cdf0e10cSrcweir if ( !pStrLink )
4185cdf0e10cSrcweir {
4186cdf0e10cSrcweir if ( pImpl->pGraphicObject )
4187cdf0e10cSrcweir *pImpl->pGraphicObject = rNewObj;
4188cdf0e10cSrcweir else
4189cdf0e10cSrcweir pImpl->pGraphicObject = new GraphicObject( rNewObj );
4190cdf0e10cSrcweir
4191cdf0e10cSrcweir ApplyGraphicTransparency_Impl();
4192cdf0e10cSrcweir
4193cdf0e10cSrcweir if ( GPOS_NONE == eGraphicPos )
4194cdf0e10cSrcweir eGraphicPos = GPOS_MM; // None waere Brush, also Default: Mitte
4195cdf0e10cSrcweir }
4196cdf0e10cSrcweir else
4197cdf0e10cSrcweir {
4198cdf0e10cSrcweir DBG_ERROR( "SetGraphic() on linked graphic! :-/" );
4199cdf0e10cSrcweir }
4200cdf0e10cSrcweir }
4201cdf0e10cSrcweir
4202cdf0e10cSrcweir // -----------------------------------------------------------------------
4203cdf0e10cSrcweir
SetGraphicLink(const String & rNew)4204cdf0e10cSrcweir void SvxBrushItem::SetGraphicLink( const String& rNew )
4205cdf0e10cSrcweir {
4206cdf0e10cSrcweir if ( !rNew.Len() )
4207cdf0e10cSrcweir DELETEZ( pStrLink );
4208cdf0e10cSrcweir else
4209cdf0e10cSrcweir {
4210cdf0e10cSrcweir if ( pStrLink )
4211cdf0e10cSrcweir *pStrLink = rNew;
4212cdf0e10cSrcweir else
4213cdf0e10cSrcweir pStrLink = new String( rNew );
4214cdf0e10cSrcweir
4215cdf0e10cSrcweir DELETEZ( pImpl->pGraphicObject );
4216cdf0e10cSrcweir }
4217cdf0e10cSrcweir }
4218cdf0e10cSrcweir
4219cdf0e10cSrcweir // -----------------------------------------------------------------------
4220cdf0e10cSrcweir
SetGraphicFilter(const String & rNew)4221cdf0e10cSrcweir void SvxBrushItem::SetGraphicFilter( const String& rNew )
4222cdf0e10cSrcweir {
4223cdf0e10cSrcweir if ( !rNew.Len() )
4224cdf0e10cSrcweir DELETEZ( pStrFilter );
4225cdf0e10cSrcweir else
4226cdf0e10cSrcweir {
4227cdf0e10cSrcweir if ( pStrFilter )
4228cdf0e10cSrcweir *pStrFilter = rNew;
4229cdf0e10cSrcweir else
4230cdf0e10cSrcweir pStrFilter = new String( rNew );
4231cdf0e10cSrcweir }
4232cdf0e10cSrcweir }
4233cdf0e10cSrcweir
4234cdf0e10cSrcweir //static
WallpaperStyle2GraphicPos(WallpaperStyle eStyle)4235cdf0e10cSrcweir SvxGraphicPosition SvxBrushItem::WallpaperStyle2GraphicPos( WallpaperStyle eStyle )
4236cdf0e10cSrcweir {
4237cdf0e10cSrcweir SvxGraphicPosition eResult;
4238cdf0e10cSrcweir // der Switch ist nicht der schnellste, dafuer aber am sichersten
4239cdf0e10cSrcweir switch( eStyle )
4240cdf0e10cSrcweir {
4241cdf0e10cSrcweir case WALLPAPER_NULL: eResult = GPOS_NONE; break;
4242cdf0e10cSrcweir case WALLPAPER_TILE: eResult = GPOS_TILED; break;
4243cdf0e10cSrcweir case WALLPAPER_CENTER: eResult = GPOS_MM; break;
4244cdf0e10cSrcweir case WALLPAPER_SCALE: eResult = GPOS_AREA; break;
4245cdf0e10cSrcweir case WALLPAPER_TOPLEFT: eResult = GPOS_LT; break;
4246cdf0e10cSrcweir case WALLPAPER_TOP: eResult = GPOS_MT; break;
4247cdf0e10cSrcweir case WALLPAPER_TOPRIGHT: eResult = GPOS_RT; break;
4248cdf0e10cSrcweir case WALLPAPER_LEFT: eResult = GPOS_LM; break;
4249cdf0e10cSrcweir case WALLPAPER_RIGHT: eResult = GPOS_RM; break;
4250cdf0e10cSrcweir case WALLPAPER_BOTTOMLEFT: eResult = GPOS_LB; break;
4251cdf0e10cSrcweir case WALLPAPER_BOTTOM: eResult = GPOS_MB; break;
4252cdf0e10cSrcweir case WALLPAPER_BOTTOMRIGHT: eResult = GPOS_RB; break;
4253cdf0e10cSrcweir default: eResult = GPOS_NONE;
4254cdf0e10cSrcweir }
4255cdf0e10cSrcweir return eResult;
4256cdf0e10cSrcweir };
4257cdf0e10cSrcweir
4258cdf0e10cSrcweir //static
GraphicPos2WallpaperStyle(SvxGraphicPosition ePos)4259cdf0e10cSrcweir WallpaperStyle SvxBrushItem::GraphicPos2WallpaperStyle( SvxGraphicPosition ePos )
4260cdf0e10cSrcweir {
4261cdf0e10cSrcweir WallpaperStyle eResult;
4262cdf0e10cSrcweir switch( ePos )
4263cdf0e10cSrcweir {
4264cdf0e10cSrcweir case GPOS_NONE: eResult = WALLPAPER_NULL; break;
4265cdf0e10cSrcweir case GPOS_TILED: eResult = WALLPAPER_TILE; break;
4266cdf0e10cSrcweir case GPOS_MM: eResult = WALLPAPER_CENTER; break;
4267cdf0e10cSrcweir case GPOS_AREA: eResult = WALLPAPER_SCALE; break;
4268cdf0e10cSrcweir case GPOS_LT: eResult = WALLPAPER_TOPLEFT; break;
4269cdf0e10cSrcweir case GPOS_MT: eResult = WALLPAPER_TOP; break;
4270cdf0e10cSrcweir case GPOS_RT: eResult = WALLPAPER_TOPRIGHT; break;
4271cdf0e10cSrcweir case GPOS_LM: eResult = WALLPAPER_LEFT; break;
4272cdf0e10cSrcweir case GPOS_RM: eResult = WALLPAPER_RIGHT; break;
4273cdf0e10cSrcweir case GPOS_LB: eResult = WALLPAPER_BOTTOMLEFT; break;
4274cdf0e10cSrcweir case GPOS_MB: eResult = WALLPAPER_BOTTOM; break;
4275cdf0e10cSrcweir case GPOS_RB: eResult = WALLPAPER_BOTTOMRIGHT; break;
4276cdf0e10cSrcweir default: eResult = WALLPAPER_NULL;
4277cdf0e10cSrcweir }
4278cdf0e10cSrcweir return eResult;
4279cdf0e10cSrcweir }
4280cdf0e10cSrcweir
4281cdf0e10cSrcweir
SvxBrushItem(const CntWallpaperItem & rItem,sal_uInt16 _nWhich)4282cdf0e10cSrcweir SvxBrushItem::SvxBrushItem( const CntWallpaperItem& rItem, sal_uInt16 _nWhich ) :
4283cdf0e10cSrcweir SfxPoolItem( _nWhich ),
4284cdf0e10cSrcweir pImpl( new SvxBrushItem_Impl( 0 ) ),
4285cdf0e10cSrcweir pStrLink(0),
4286cdf0e10cSrcweir pStrFilter(0),
4287cdf0e10cSrcweir bLoadAgain( sal_True )
4288cdf0e10cSrcweir {
4289cdf0e10cSrcweir aColor = rItem.GetColor();
4290cdf0e10cSrcweir
4291cdf0e10cSrcweir if( rItem.GetBitmapURL().Len() )
4292cdf0e10cSrcweir {
4293cdf0e10cSrcweir pStrLink = new String( rItem.GetBitmapURL() );
4294cdf0e10cSrcweir SetGraphicPos( WallpaperStyle2GraphicPos((WallpaperStyle)rItem.GetStyle() ) );
4295cdf0e10cSrcweir }
4296cdf0e10cSrcweir }
4297cdf0e10cSrcweir
CreateCntWallpaperItem() const4298cdf0e10cSrcweir CntWallpaperItem* SvxBrushItem::CreateCntWallpaperItem() const
4299cdf0e10cSrcweir {
4300cdf0e10cSrcweir CntWallpaperItem* pItem = new CntWallpaperItem( 0 );
4301cdf0e10cSrcweir pItem->SetColor( aColor.GetColor() );
4302cdf0e10cSrcweir pItem->SetStyle( (sal_uInt16)GraphicPos2WallpaperStyle( GetGraphicPos() ) );
4303cdf0e10cSrcweir sal_Bool bLink = (pStrLink != 0);
4304cdf0e10cSrcweir if( bLink )
4305cdf0e10cSrcweir {
4306cdf0e10cSrcweir String aURL = *pStrLink;
4307cdf0e10cSrcweir pItem->SetBitmapURL( aURL );
4308cdf0e10cSrcweir }
4309cdf0e10cSrcweir if( pImpl->pGraphicObject )
4310cdf0e10cSrcweir {
4311cdf0e10cSrcweir DBG_ERRORFILE( "Don't know what to do with a graphic" );
4312cdf0e10cSrcweir }
4313cdf0e10cSrcweir // pItem->SetGraphic( *pImpl->pGraphic, bLink );
4314cdf0e10cSrcweir
4315cdf0e10cSrcweir return pItem;
4316cdf0e10cSrcweir }
4317cdf0e10cSrcweir
4318cdf0e10cSrcweir #ifdef _MSC_VER
4319cdf0e10cSrcweir #pragma optimize ( "", on )
4320cdf0e10cSrcweir #endif
4321cdf0e10cSrcweir /* -----------------------------16.08.2002 09:18------------------------------
4322cdf0e10cSrcweir
4323cdf0e10cSrcweir ---------------------------------------------------------------------------*/
ApplyGraphicTransparency_Impl()4324cdf0e10cSrcweir void SvxBrushItem::ApplyGraphicTransparency_Impl()
4325cdf0e10cSrcweir {
4326cdf0e10cSrcweir DBG_ASSERT(pImpl->pGraphicObject, "no GraphicObject available" );
4327cdf0e10cSrcweir if(pImpl->pGraphicObject)
4328cdf0e10cSrcweir {
4329cdf0e10cSrcweir GraphicAttr aAttr(pImpl->pGraphicObject->GetAttr());
4330cdf0e10cSrcweir aAttr.SetTransparency(lcl_PercentToTransparency(
4331cdf0e10cSrcweir pImpl->nGraphicTransparency));
4332cdf0e10cSrcweir pImpl->pGraphicObject->SetAttr(aAttr);
4333cdf0e10cSrcweir }
4334cdf0e10cSrcweir }
4335cdf0e10cSrcweir // class SvxFrameDirectionItem ----------------------------------------------
4336cdf0e10cSrcweir
SvxFrameDirectionItem(sal_uInt16 _nWhich)4337cdf0e10cSrcweir SvxFrameDirectionItem::SvxFrameDirectionItem( sal_uInt16 _nWhich )
4338cdf0e10cSrcweir : SfxUInt16Item( _nWhich, (sal_uInt16)FRMDIR_HORI_LEFT_TOP )
4339cdf0e10cSrcweir {
4340cdf0e10cSrcweir }
4341cdf0e10cSrcweir
SvxFrameDirectionItem(SvxFrameDirection nValue,sal_uInt16 _nWhich)4342cdf0e10cSrcweir SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue ,
4343cdf0e10cSrcweir sal_uInt16 _nWhich )
4344cdf0e10cSrcweir : SfxUInt16Item( _nWhich, (sal_uInt16)nValue )
4345cdf0e10cSrcweir {
4346cdf0e10cSrcweir }
4347cdf0e10cSrcweir
~SvxFrameDirectionItem()4348cdf0e10cSrcweir SvxFrameDirectionItem::~SvxFrameDirectionItem()
4349cdf0e10cSrcweir {
4350cdf0e10cSrcweir }
4351cdf0e10cSrcweir
operator ==(const SfxPoolItem & rCmp) const4352cdf0e10cSrcweir int SvxFrameDirectionItem::operator==( const SfxPoolItem& rCmp ) const
4353cdf0e10cSrcweir {
4354cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rCmp), "unequal types" );
4355cdf0e10cSrcweir
4356cdf0e10cSrcweir return GetValue() == ((SvxFrameDirectionItem&)rCmp).GetValue();
4357cdf0e10cSrcweir }
4358cdf0e10cSrcweir
Clone(SfxItemPool *) const4359cdf0e10cSrcweir SfxPoolItem* SvxFrameDirectionItem::Clone( SfxItemPool * ) const
4360cdf0e10cSrcweir {
4361cdf0e10cSrcweir return new SvxFrameDirectionItem( *this );
4362cdf0e10cSrcweir }
4363cdf0e10cSrcweir
Create(SvStream & rStrm,sal_uInt16) const4364cdf0e10cSrcweir SfxPoolItem* SvxFrameDirectionItem::Create( SvStream & rStrm, sal_uInt16 /*nVer*/ ) const
4365cdf0e10cSrcweir {
4366cdf0e10cSrcweir sal_uInt16 nValue;
4367cdf0e10cSrcweir rStrm >> nValue;
4368cdf0e10cSrcweir return new SvxFrameDirectionItem( (SvxFrameDirection)nValue, Which() );
4369cdf0e10cSrcweir }
4370cdf0e10cSrcweir
Store(SvStream & rStrm,sal_uInt16) const4371cdf0e10cSrcweir SvStream& SvxFrameDirectionItem::Store( SvStream & rStrm, sal_uInt16 /*nIVer*/ ) const
4372cdf0e10cSrcweir {
4373cdf0e10cSrcweir sal_uInt16 nValue = GetValue();
4374cdf0e10cSrcweir rStrm << nValue;
4375cdf0e10cSrcweir return rStrm;
4376cdf0e10cSrcweir }
4377cdf0e10cSrcweir
GetVersion(sal_uInt16 nFVer) const4378cdf0e10cSrcweir sal_uInt16 SvxFrameDirectionItem::GetVersion( sal_uInt16 nFVer ) const
4379cdf0e10cSrcweir {
4380cdf0e10cSrcweir return SOFFICE_FILEFORMAT_50 > nFVer ? USHRT_MAX : 0;
4381cdf0e10cSrcweir }
4382cdf0e10cSrcweir
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const4383cdf0e10cSrcweir SfxItemPresentation SvxFrameDirectionItem::GetPresentation(
4384cdf0e10cSrcweir SfxItemPresentation ePres,
4385cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/,
4386cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/,
4387cdf0e10cSrcweir XubString& rText, const IntlWrapper *) const
4388cdf0e10cSrcweir {
4389cdf0e10cSrcweir SfxItemPresentation eRet = ePres;
4390cdf0e10cSrcweir switch( ePres )
4391cdf0e10cSrcweir {
4392cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE:
4393cdf0e10cSrcweir rText.Erase();
4394cdf0e10cSrcweir break;
4395cdf0e10cSrcweir
4396cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS:
4397cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE:
4398cdf0e10cSrcweir rText = EE_RESSTR( RID_SVXITEMS_FRMDIR_BEGIN + GetValue() );
4399cdf0e10cSrcweir break;
4400cdf0e10cSrcweir
4401cdf0e10cSrcweir default:
4402cdf0e10cSrcweir eRet = SFX_ITEM_PRESENTATION_NONE;
4403cdf0e10cSrcweir }
4404cdf0e10cSrcweir return eRet;
4405cdf0e10cSrcweir }
4406cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)4407cdf0e10cSrcweir sal_Bool SvxFrameDirectionItem::PutValue( const com::sun::star::uno::Any& rVal,
4408cdf0e10cSrcweir sal_uInt8 )
4409cdf0e10cSrcweir {
4410cdf0e10cSrcweir sal_Int16 nVal = sal_Int16();
4411cdf0e10cSrcweir sal_Bool bRet = ( rVal >>= nVal );
4412cdf0e10cSrcweir if( bRet )
4413cdf0e10cSrcweir {
4414cdf0e10cSrcweir // translate WritingDirection2 constants into SvxFrameDirection
4415cdf0e10cSrcweir switch( nVal )
4416cdf0e10cSrcweir {
4417cdf0e10cSrcweir case text::WritingMode2::LR_TB:
4418cdf0e10cSrcweir SetValue( FRMDIR_HORI_LEFT_TOP );
4419cdf0e10cSrcweir break;
4420cdf0e10cSrcweir case text::WritingMode2::RL_TB:
4421cdf0e10cSrcweir SetValue( FRMDIR_HORI_RIGHT_TOP );
4422cdf0e10cSrcweir break;
4423cdf0e10cSrcweir case text::WritingMode2::TB_RL:
4424cdf0e10cSrcweir SetValue( FRMDIR_VERT_TOP_RIGHT );
4425cdf0e10cSrcweir break;
4426cdf0e10cSrcweir case text::WritingMode2::TB_LR:
4427cdf0e10cSrcweir SetValue( FRMDIR_VERT_TOP_LEFT );
4428cdf0e10cSrcweir break;
4429cdf0e10cSrcweir case text::WritingMode2::PAGE:
4430cdf0e10cSrcweir SetValue( FRMDIR_ENVIRONMENT );
4431cdf0e10cSrcweir break;
4432cdf0e10cSrcweir default:
4433cdf0e10cSrcweir bRet = sal_False;
4434cdf0e10cSrcweir break;
4435cdf0e10cSrcweir }
4436cdf0e10cSrcweir }
4437cdf0e10cSrcweir
4438cdf0e10cSrcweir return bRet;
4439cdf0e10cSrcweir }
4440cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const4441cdf0e10cSrcweir sal_Bool SvxFrameDirectionItem::QueryValue( com::sun::star::uno::Any& rVal,
4442cdf0e10cSrcweir sal_uInt8 ) const
4443cdf0e10cSrcweir {
4444cdf0e10cSrcweir // translate SvxFrameDirection into WritingDirection2
4445cdf0e10cSrcweir sal_Int16 nVal;
4446cdf0e10cSrcweir sal_Bool bRet = sal_True;
4447cdf0e10cSrcweir switch( GetValue() )
4448cdf0e10cSrcweir {
4449cdf0e10cSrcweir case FRMDIR_HORI_LEFT_TOP:
4450cdf0e10cSrcweir nVal = text::WritingMode2::LR_TB;
4451cdf0e10cSrcweir break;
4452cdf0e10cSrcweir case FRMDIR_HORI_RIGHT_TOP:
4453cdf0e10cSrcweir nVal = text::WritingMode2::RL_TB;
4454cdf0e10cSrcweir break;
4455cdf0e10cSrcweir case FRMDIR_VERT_TOP_RIGHT:
4456cdf0e10cSrcweir nVal = text::WritingMode2::TB_RL;
4457cdf0e10cSrcweir break;
4458cdf0e10cSrcweir case FRMDIR_VERT_TOP_LEFT:
4459cdf0e10cSrcweir nVal = text::WritingMode2::TB_LR;
4460cdf0e10cSrcweir break;
4461cdf0e10cSrcweir case FRMDIR_ENVIRONMENT:
4462cdf0e10cSrcweir nVal = text::WritingMode2::PAGE;
4463cdf0e10cSrcweir break;
4464cdf0e10cSrcweir default:
4465cdf0e10cSrcweir DBG_ERROR("Unknown SvxFrameDirection value!");
4466cdf0e10cSrcweir bRet = sal_False;
4467cdf0e10cSrcweir break;
4468cdf0e10cSrcweir }
4469cdf0e10cSrcweir
4470cdf0e10cSrcweir // return value + error state
4471cdf0e10cSrcweir if( bRet )
4472cdf0e10cSrcweir {
4473cdf0e10cSrcweir rVal <<= nVal;
4474cdf0e10cSrcweir }
4475cdf0e10cSrcweir return bRet;
4476cdf0e10cSrcweir }
4477cdf0e10cSrcweir
4478