1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*190118d0SAndrew Rist * distributed with this work for additional information
6*190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist * with the License. You may obtain a copy of the License at
10*190118d0SAndrew Rist *
11*190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*190118d0SAndrew Rist *
13*190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist * software distributed under the License is distributed on an
15*190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist * KIND, either express or implied. See the License for the
17*190118d0SAndrew Rist * specific language governing permissions and limitations
18*190118d0SAndrew Rist * under the License.
19*190118d0SAndrew Rist *
20*190118d0SAndrew Rist *************************************************************/
21*190118d0SAndrew Rist
22*190118d0SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <editeng/numitem.hxx>
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
30cdf0e10cSrcweir #include <com/sun/star/text/VertOrientation.hpp>
31cdf0e10cSrcweir #include <com/sun/star/text/RelOrientation.hpp>
32cdf0e10cSrcweir #include <editeng/brshitem.hxx>
33cdf0e10cSrcweir #include <vcl/font.hxx>
34cdf0e10cSrcweir #include <editeng/editids.hrc>
35cdf0e10cSrcweir #include <editeng/editrids.hrc>
36cdf0e10cSrcweir #include <editeng/numdef.hxx>
37cdf0e10cSrcweir #include <vcl/graph.hxx>
38cdf0e10cSrcweir #include <vcl/window.hxx>
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #include <editeng/unolingu.hxx>
41cdf0e10cSrcweir #include <com/sun/star/text/XNumberingFormatter.hpp>
42cdf0e10cSrcweir #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
43cdf0e10cSrcweir #include <com/sun/star/style/NumberingType.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
46cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir #include <editeng/unonrule.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir #define MM100_TO_TWIP(MM100) ((MM100*72L+63L)/127L)
51cdf0e10cSrcweir
52cdf0e10cSrcweir #define DEF_WRITER_LSPACE 500 //Standardeinrueckung
53cdf0e10cSrcweir #define DEF_DRAW_LSPACE 800 //Standardeinrueckung
54cdf0e10cSrcweir
55cdf0e10cSrcweir #define NUMITEM_VERSION_01 0x01
56cdf0e10cSrcweir #define NUMITEM_VERSION_02 0x02
57cdf0e10cSrcweir #define NUMITEM_VERSION_03 0x03
58cdf0e10cSrcweir #define NUMITEM_VERSION_04 0x04
59cdf0e10cSrcweir
60cdf0e10cSrcweir using namespace ::com::sun::star;
61cdf0e10cSrcweir using namespace ::com::sun::star::lang;
62cdf0e10cSrcweir using namespace ::com::sun::star::uno;
63cdf0e10cSrcweir using namespace ::com::sun::star::text;
64cdf0e10cSrcweir using namespace ::com::sun::star::beans;
65cdf0e10cSrcweir using namespace ::com::sun::star::style;
66cdf0e10cSrcweir
67cdf0e10cSrcweir sal_Int32 SvxNumberType::nRefCount = 0;
68cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> SvxNumberType::xFormatter = 0;
lcl_getFormatter(com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter> & _xFormatter)69cdf0e10cSrcweir void lcl_getFormatter(com::sun::star::uno::Reference<com::sun::star::text::XNumberingFormatter>& _xFormatter)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir if(!_xFormatter.is())
72cdf0e10cSrcweir {
73cdf0e10cSrcweir try
74cdf0e10cSrcweir {
75cdf0e10cSrcweir Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
76cdf0e10cSrcweir Reference < XInterface > xI = xMSF->createInstance(
77cdf0e10cSrcweir ::rtl::OUString::createFromAscii( "com.sun.star.text.DefaultNumberingProvider" ) );
78cdf0e10cSrcweir Reference<XDefaultNumberingProvider> xRet(xI, UNO_QUERY);
79cdf0e10cSrcweir DBG_ASSERT(xRet.is(), "service missing: \"com.sun.star.text.DefaultNumberingProvider\"");
80cdf0e10cSrcweir _xFormatter = Reference<XNumberingFormatter> (xRet, UNO_QUERY);
81cdf0e10cSrcweir }
82cdf0e10cSrcweir catch(Exception& )
83cdf0e10cSrcweir {
84cdf0e10cSrcweir }
85cdf0e10cSrcweir }
86cdf0e10cSrcweir }
87cdf0e10cSrcweir /* -----------------------------22.02.01 14:24--------------------------------
88cdf0e10cSrcweir
89cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SvxNumberType(sal_Int16 nType)90cdf0e10cSrcweir SvxNumberType::SvxNumberType(sal_Int16 nType) :
91cdf0e10cSrcweir nNumType(nType),
92cdf0e10cSrcweir bShowSymbol(sal_True)
93cdf0e10cSrcweir {
94cdf0e10cSrcweir nRefCount++;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir /* -----------------------------22.02.01 14:31--------------------------------
97cdf0e10cSrcweir
98cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SvxNumberType(const SvxNumberType & rType)99cdf0e10cSrcweir SvxNumberType::SvxNumberType(const SvxNumberType& rType) :
100cdf0e10cSrcweir nNumType(rType.nNumType),
101cdf0e10cSrcweir bShowSymbol(rType.bShowSymbol)
102cdf0e10cSrcweir {
103cdf0e10cSrcweir nRefCount++;
104cdf0e10cSrcweir }
105cdf0e10cSrcweir /* -----------------------------22.02.01 14:24--------------------------------
106cdf0e10cSrcweir
107cdf0e10cSrcweir ---------------------------------------------------------------------------*/
~SvxNumberType()108cdf0e10cSrcweir SvxNumberType::~SvxNumberType()
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if(!--nRefCount)
111cdf0e10cSrcweir xFormatter = 0;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir /* -----------------------------22.02.01 11:09--------------------------------
114cdf0e10cSrcweir
115cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetNumStr(sal_uLong nNo) const116cdf0e10cSrcweir String SvxNumberType::GetNumStr( sal_uLong nNo ) const
117cdf0e10cSrcweir {
118cdf0e10cSrcweir LanguageType eLang = Application::GetSettings().GetLanguage();
119cdf0e10cSrcweir Locale aLocale = SvxCreateLocale(eLang);
120cdf0e10cSrcweir return GetNumStr( nNo, aLocale );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir /* -----------------28.10.98 15:56-------------------
123cdf0e10cSrcweir *
124cdf0e10cSrcweir * --------------------------------------------------*/
GetNumStr(sal_uLong nNo,const Locale & rLocale) const125cdf0e10cSrcweir String SvxNumberType::GetNumStr( sal_uLong nNo, const Locale& rLocale ) const
126cdf0e10cSrcweir {
127cdf0e10cSrcweir lcl_getFormatter(xFormatter);
128cdf0e10cSrcweir String aTmpStr;
129cdf0e10cSrcweir if(!xFormatter.is())
130cdf0e10cSrcweir return aTmpStr;
131cdf0e10cSrcweir
132cdf0e10cSrcweir if(bShowSymbol)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir switch(nNumType)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir case NumberingType::CHAR_SPECIAL:
137cdf0e10cSrcweir case NumberingType::BITMAP:
138cdf0e10cSrcweir break;
139cdf0e10cSrcweir default:
140cdf0e10cSrcweir {
141cdf0e10cSrcweir //#95525# '0' allowed for ARABIC numberings
142cdf0e10cSrcweir if(NumberingType::ARABIC == nNumType && 0 == nNo )
143cdf0e10cSrcweir aTmpStr = '0';
144cdf0e10cSrcweir else
145cdf0e10cSrcweir {
146cdf0e10cSrcweir Sequence< PropertyValue > aProperties(2);
147cdf0e10cSrcweir PropertyValue* pValues = aProperties.getArray();
148cdf0e10cSrcweir pValues[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingType"));
149cdf0e10cSrcweir pValues[0].Value <<= nNumType;
150cdf0e10cSrcweir pValues[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
151cdf0e10cSrcweir pValues[1].Value <<= (sal_Int32)nNo;
152cdf0e10cSrcweir
153cdf0e10cSrcweir try
154cdf0e10cSrcweir {
155cdf0e10cSrcweir aTmpStr = xFormatter->makeNumberingString( aProperties, rLocale );
156cdf0e10cSrcweir }
157cdf0e10cSrcweir catch(Exception&)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir }
162cdf0e10cSrcweir }
163cdf0e10cSrcweir }
164cdf0e10cSrcweir return aTmpStr;
165cdf0e10cSrcweir }
166cdf0e10cSrcweir /* -----------------27.10.98 10:33-------------------
167cdf0e10cSrcweir *
168cdf0e10cSrcweir * --------------------------------------------------*/
169cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
SvxNumberFormat(sal_Int16 eType,SvxNumPositionAndSpaceMode ePositionAndSpaceMode)170cdf0e10cSrcweir SvxNumberFormat::SvxNumberFormat( sal_Int16 eType,
171cdf0e10cSrcweir SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
172cdf0e10cSrcweir // <--
173cdf0e10cSrcweir : SvxNumberType(eType),
174cdf0e10cSrcweir eNumAdjust(SVX_ADJUST_LEFT),
175cdf0e10cSrcweir nInclUpperLevels(0),
176cdf0e10cSrcweir nStart(1),
177cdf0e10cSrcweir cBullet(SVX_DEF_BULLET),
178cdf0e10cSrcweir nBulletRelSize(100),
179cdf0e10cSrcweir nBulletColor(COL_BLACK),
180cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
181cdf0e10cSrcweir mePositionAndSpaceMode( ePositionAndSpaceMode ),
182cdf0e10cSrcweir // <--
183cdf0e10cSrcweir nFirstLineOffset(0),
184cdf0e10cSrcweir nAbsLSpace(0),
185cdf0e10cSrcweir nLSpace(0),
186cdf0e10cSrcweir nCharTextDistance(0),
187cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
188cdf0e10cSrcweir meLabelFollowedBy( LISTTAB ),
189cdf0e10cSrcweir mnListtabPos( 0 ),
190cdf0e10cSrcweir mnFirstLineIndent( 0 ),
191cdf0e10cSrcweir mnIndentAt( 0 ),
192cdf0e10cSrcweir // <--
193cdf0e10cSrcweir pGraphicBrush(0),
194cdf0e10cSrcweir eVertOrient(text::VertOrientation::NONE),
195cdf0e10cSrcweir pBulletFont(0)
196cdf0e10cSrcweir {
197cdf0e10cSrcweir }
198cdf0e10cSrcweir /* -----------------27.10.98 10:56-------------------
199cdf0e10cSrcweir *
200cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumberFormat(const SvxNumberFormat & rFormat)201cdf0e10cSrcweir SvxNumberFormat::SvxNumberFormat(const SvxNumberFormat& rFormat) :
202cdf0e10cSrcweir SvxNumberType(rFormat),
203cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
204cdf0e10cSrcweir mePositionAndSpaceMode( rFormat.mePositionAndSpaceMode ),
205cdf0e10cSrcweir // <--
206cdf0e10cSrcweir pGraphicBrush(0),
207cdf0e10cSrcweir pBulletFont(0)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir *this = rFormat;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir /* -----------------27.10.98 10:56-------------------
212cdf0e10cSrcweir *
213cdf0e10cSrcweir * --------------------------------------------------*/
~SvxNumberFormat()214cdf0e10cSrcweir SvxNumberFormat::~SvxNumberFormat()
215cdf0e10cSrcweir {
216cdf0e10cSrcweir delete pGraphicBrush;
217cdf0e10cSrcweir delete pBulletFont;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir /* -----------------08.12.98 11:14-------------------
220cdf0e10cSrcweir *
221cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumberFormat(SvStream & rStream)222cdf0e10cSrcweir SvxNumberFormat::SvxNumberFormat(SvStream &rStream)
223cdf0e10cSrcweir : mePositionAndSpaceMode( LABEL_WIDTH_AND_POSITION ),
224cdf0e10cSrcweir meLabelFollowedBy( LISTTAB ),
225cdf0e10cSrcweir mnListtabPos( 0 ),
226cdf0e10cSrcweir mnFirstLineIndent( 0 ),
227cdf0e10cSrcweir mnIndentAt( 0 )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir
230cdf0e10cSrcweir sal_uInt16 nVersion;
231cdf0e10cSrcweir rStream >> nVersion;
232cdf0e10cSrcweir
233cdf0e10cSrcweir sal_uInt16 nUSHORT;
234cdf0e10cSrcweir rStream >> nUSHORT;
235cdf0e10cSrcweir SetNumberingType((sal_Int16)nUSHORT);
236cdf0e10cSrcweir rStream >> nUSHORT;
237cdf0e10cSrcweir eNumAdjust = (SvxAdjust)nUSHORT;
238cdf0e10cSrcweir rStream >> nUSHORT;
239cdf0e10cSrcweir nInclUpperLevels = (sal_uInt8)nUSHORT;
240cdf0e10cSrcweir rStream >> nUSHORT;
241cdf0e10cSrcweir nStart = nUSHORT;
242cdf0e10cSrcweir rStream >> nUSHORT;
243cdf0e10cSrcweir cBullet = nUSHORT;
244cdf0e10cSrcweir
245cdf0e10cSrcweir short nShort;
246cdf0e10cSrcweir rStream >> nShort;
247cdf0e10cSrcweir nFirstLineOffset = nShort;
248cdf0e10cSrcweir rStream >> nShort;
249cdf0e10cSrcweir nAbsLSpace = nShort;
250cdf0e10cSrcweir rStream >> nShort;
251cdf0e10cSrcweir nLSpace = nShort;
252cdf0e10cSrcweir
253cdf0e10cSrcweir rStream >> nShort;
254cdf0e10cSrcweir nCharTextDistance = nShort;
255cdf0e10cSrcweir rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
256cdf0e10cSrcweir rStream.ReadByteString(sPrefix, eEnc);
257cdf0e10cSrcweir rStream.ReadByteString(sSuffix, eEnc);
258cdf0e10cSrcweir rStream.ReadByteString(sCharStyleName, eEnc);
259cdf0e10cSrcweir rStream >> nUSHORT;
260cdf0e10cSrcweir if(nUSHORT)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir SvxBrushItem aHelper(0);
263cdf0e10cSrcweir pGraphicBrush = (SvxBrushItem*) aHelper.Create( rStream, BRUSH_GRAPHIC_VERSION );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir else
266cdf0e10cSrcweir pGraphicBrush = 0;
267cdf0e10cSrcweir
268cdf0e10cSrcweir rStream >> nUSHORT;
269cdf0e10cSrcweir eVertOrient = (sal_Int16)nUSHORT;
270cdf0e10cSrcweir
271cdf0e10cSrcweir rStream >> nUSHORT;
272cdf0e10cSrcweir if(nUSHORT)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir pBulletFont = new Font;
275cdf0e10cSrcweir rStream >> *pBulletFont;
276cdf0e10cSrcweir if(!pBulletFont->GetCharSet())
277cdf0e10cSrcweir pBulletFont->SetCharSet(rStream.GetStreamCharSet());
278cdf0e10cSrcweir }
279cdf0e10cSrcweir else
280cdf0e10cSrcweir pBulletFont = 0;
281cdf0e10cSrcweir rStream >> aGraphicSize;
282cdf0e10cSrcweir
283cdf0e10cSrcweir rStream >> nBulletColor;
284cdf0e10cSrcweir rStream >> nUSHORT;
285cdf0e10cSrcweir nBulletRelSize = nUSHORT;
286cdf0e10cSrcweir rStream >> nUSHORT;
287cdf0e10cSrcweir SetShowSymbol((sal_Bool)nUSHORT);
288cdf0e10cSrcweir
289cdf0e10cSrcweir if( nVersion < NUMITEM_VERSION_03 )
290cdf0e10cSrcweir cBullet = ByteString::ConvertToUnicode( (sal_Char)cBullet,
291cdf0e10cSrcweir (pBulletFont&&pBulletFont->GetCharSet()) ? pBulletFont->GetCharSet()
292cdf0e10cSrcweir : RTL_TEXTENCODING_SYMBOL );
293cdf0e10cSrcweir if(pBulletFont)
294cdf0e10cSrcweir {
295cdf0e10cSrcweir sal_Bool bConvertBulletFont = rStream.GetVersion() <= SOFFICE_FILEFORMAT_50;
296cdf0e10cSrcweir if(bConvertBulletFont)
297cdf0e10cSrcweir {
298cdf0e10cSrcweir
299cdf0e10cSrcweir FontToSubsFontConverter pConverter =
300cdf0e10cSrcweir CreateFontToSubsFontConverter(pBulletFont->GetName(),
301cdf0e10cSrcweir FONTTOSUBSFONT_IMPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS);
302cdf0e10cSrcweir if(pConverter)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir cBullet = ConvertFontToSubsFontChar(pConverter, cBullet);
305cdf0e10cSrcweir String sFontName = GetFontToSubsFontName(pConverter);
306cdf0e10cSrcweir pBulletFont->SetName(sFontName);
307cdf0e10cSrcweir DestroyFontToSubsFontConverter(pConverter);
308cdf0e10cSrcweir }
309cdf0e10cSrcweir }
310cdf0e10cSrcweir }
311cdf0e10cSrcweir
312cdf0e10cSrcweir if( NUMITEM_VERSION_04 <= nVersion )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir rStream >> nUSHORT;
315cdf0e10cSrcweir mePositionAndSpaceMode = (SvxNumPositionAndSpaceMode) nUSHORT;
316cdf0e10cSrcweir rStream >> nUSHORT;
317cdf0e10cSrcweir meLabelFollowedBy = ( SvxNumLabelFollowedBy ) nUSHORT;
318cdf0e10cSrcweir long nLong;
319cdf0e10cSrcweir rStream >> nLong;
320cdf0e10cSrcweir mnListtabPos = nLong;
321cdf0e10cSrcweir rStream >> nLong;
322cdf0e10cSrcweir mnFirstLineIndent = nLong;
323cdf0e10cSrcweir rStream >> nLong;
324cdf0e10cSrcweir mnIndentAt = nLong;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir /* -----------------08.12.98 11:14-------------------
328cdf0e10cSrcweir *
329cdf0e10cSrcweir * --------------------------------------------------*/
Store(SvStream & rStream,FontToSubsFontConverter pConverter)330cdf0e10cSrcweir SvStream& SvxNumberFormat::Store(SvStream &rStream, FontToSubsFontConverter pConverter)
331cdf0e10cSrcweir {
332cdf0e10cSrcweir if(pConverter && pBulletFont)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir cBullet = ConvertFontToSubsFontChar(pConverter, cBullet);
335cdf0e10cSrcweir String sFontName = GetFontToSubsFontName(pConverter);
336cdf0e10cSrcweir pBulletFont->SetName(sFontName);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir
339cdf0e10cSrcweir rStream << (sal_uInt16)NUMITEM_VERSION_04;
340cdf0e10cSrcweir
341cdf0e10cSrcweir rStream << (sal_uInt16)GetNumberingType();
342cdf0e10cSrcweir rStream << (sal_uInt16)eNumAdjust;
343cdf0e10cSrcweir rStream << (sal_uInt16)nInclUpperLevels;
344cdf0e10cSrcweir rStream << nStart;
345cdf0e10cSrcweir rStream << (sal_uInt16)cBullet;
346cdf0e10cSrcweir
347cdf0e10cSrcweir rStream << nFirstLineOffset;
348cdf0e10cSrcweir rStream << nAbsLSpace;
349cdf0e10cSrcweir rStream << nLSpace;
350cdf0e10cSrcweir
351cdf0e10cSrcweir rStream << nCharTextDistance;
352cdf0e10cSrcweir rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
353cdf0e10cSrcweir rStream.WriteByteString(sPrefix, eEnc);
354cdf0e10cSrcweir rStream.WriteByteString(sSuffix, eEnc);
355cdf0e10cSrcweir rStream.WriteByteString(sCharStyleName, eEnc);
356cdf0e10cSrcweir if(pGraphicBrush)
357cdf0e10cSrcweir {
358cdf0e10cSrcweir rStream << (sal_uInt16)1;
359cdf0e10cSrcweir
360cdf0e10cSrcweir // #75113# in SD or SI force bullet itself to be stored,
361cdf0e10cSrcweir // for that purpose throw away link when link and graphic
362cdf0e10cSrcweir // are present, so Brush save is forced
363cdf0e10cSrcweir if(pGraphicBrush->GetGraphicLink() && pGraphicBrush->GetGraphic())
364cdf0e10cSrcweir {
365cdf0e10cSrcweir String aEmpty;
366cdf0e10cSrcweir pGraphicBrush->SetGraphicLink(aEmpty);
367cdf0e10cSrcweir }
368cdf0e10cSrcweir
369cdf0e10cSrcweir pGraphicBrush->Store(rStream, BRUSH_GRAPHIC_VERSION);
370cdf0e10cSrcweir }
371cdf0e10cSrcweir else
372cdf0e10cSrcweir rStream << (sal_uInt16)0;
373cdf0e10cSrcweir
374cdf0e10cSrcweir rStream << (sal_uInt16)eVertOrient;
375cdf0e10cSrcweir if(pBulletFont)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir rStream << (sal_uInt16)1;
378cdf0e10cSrcweir rStream << *pBulletFont;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir else
381cdf0e10cSrcweir rStream << (sal_uInt16)0;
382cdf0e10cSrcweir rStream << aGraphicSize;
383cdf0e10cSrcweir
384cdf0e10cSrcweir Color nTempColor = nBulletColor;
385cdf0e10cSrcweir if(COL_AUTO == nBulletColor.GetColor())
386cdf0e10cSrcweir nTempColor = COL_BLACK;
387cdf0e10cSrcweir rStream << nTempColor;
388cdf0e10cSrcweir rStream << nBulletRelSize;
389cdf0e10cSrcweir rStream << (sal_uInt16)IsShowSymbol();
390cdf0e10cSrcweir
391cdf0e10cSrcweir rStream << ( sal_uInt16 ) mePositionAndSpaceMode;
392cdf0e10cSrcweir rStream << ( sal_uInt16 ) meLabelFollowedBy;
393cdf0e10cSrcweir rStream << ( long ) mnListtabPos;
394cdf0e10cSrcweir rStream << ( long ) mnFirstLineIndent;
395cdf0e10cSrcweir rStream << ( long ) mnIndentAt;
396cdf0e10cSrcweir
397cdf0e10cSrcweir return rStream;
398cdf0e10cSrcweir }
399cdf0e10cSrcweir
400cdf0e10cSrcweir /* -----------------------------23.02.01 11:10--------------------------------
401cdf0e10cSrcweir
402cdf0e10cSrcweir ---------------------------------------------------------------------------*/
operator =(const SvxNumberFormat & rFormat)403cdf0e10cSrcweir SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir if (& rFormat == this) { return *this; }
406cdf0e10cSrcweir
407cdf0e10cSrcweir SetNumberingType(rFormat.GetNumberingType());
408cdf0e10cSrcweir eNumAdjust = rFormat.eNumAdjust ;
409cdf0e10cSrcweir nInclUpperLevels = rFormat.nInclUpperLevels ;
410cdf0e10cSrcweir nStart = rFormat.nStart ;
411cdf0e10cSrcweir cBullet = rFormat.cBullet ;
412cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
413cdf0e10cSrcweir mePositionAndSpaceMode = rFormat.mePositionAndSpaceMode;
414cdf0e10cSrcweir // <--
415cdf0e10cSrcweir nFirstLineOffset = rFormat.nFirstLineOffset;
416cdf0e10cSrcweir nAbsLSpace = rFormat.nAbsLSpace ;
417cdf0e10cSrcweir nLSpace = rFormat.nLSpace ;
418cdf0e10cSrcweir nCharTextDistance = rFormat.nCharTextDistance ;
419cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
420cdf0e10cSrcweir meLabelFollowedBy = rFormat.meLabelFollowedBy;
421cdf0e10cSrcweir mnListtabPos = rFormat.mnListtabPos;
422cdf0e10cSrcweir mnFirstLineIndent = rFormat.mnFirstLineIndent;
423cdf0e10cSrcweir mnIndentAt = rFormat.mnIndentAt;
424cdf0e10cSrcweir // <--
425cdf0e10cSrcweir eVertOrient = rFormat.eVertOrient ;
426cdf0e10cSrcweir sPrefix = rFormat.sPrefix ;
427cdf0e10cSrcweir sSuffix = rFormat.sSuffix ;
428cdf0e10cSrcweir aGraphicSize = rFormat.aGraphicSize ;
429cdf0e10cSrcweir nBulletColor = rFormat.nBulletColor ;
430cdf0e10cSrcweir nBulletRelSize = rFormat.nBulletRelSize;
431cdf0e10cSrcweir SetShowSymbol(rFormat.IsShowSymbol());
432cdf0e10cSrcweir sCharStyleName = rFormat.sCharStyleName;
433cdf0e10cSrcweir DELETEZ(pGraphicBrush);
434cdf0e10cSrcweir if(rFormat.pGraphicBrush)
435cdf0e10cSrcweir {
436cdf0e10cSrcweir pGraphicBrush = new SvxBrushItem(*rFormat.pGraphicBrush);
437cdf0e10cSrcweir pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
438cdf0e10cSrcweir }
439cdf0e10cSrcweir DELETEZ(pBulletFont);
440cdf0e10cSrcweir if(rFormat.pBulletFont)
441cdf0e10cSrcweir pBulletFont = new Font(*rFormat.pBulletFont);
442cdf0e10cSrcweir return *this;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir /* -----------------27.10.98 10:56-------------------
445cdf0e10cSrcweir *
446cdf0e10cSrcweir * --------------------------------------------------*/
operator ==(const SvxNumberFormat & rFormat) const447cdf0e10cSrcweir sal_Bool SvxNumberFormat::operator==( const SvxNumberFormat& rFormat) const
448cdf0e10cSrcweir {
449cdf0e10cSrcweir if( GetNumberingType() != rFormat.GetNumberingType() ||
450cdf0e10cSrcweir eNumAdjust != rFormat.eNumAdjust ||
451cdf0e10cSrcweir nInclUpperLevels != rFormat.nInclUpperLevels ||
452cdf0e10cSrcweir nStart != rFormat.nStart ||
453cdf0e10cSrcweir cBullet != rFormat.cBullet ||
454cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
455cdf0e10cSrcweir mePositionAndSpaceMode != rFormat.mePositionAndSpaceMode ||
456cdf0e10cSrcweir // <--
457cdf0e10cSrcweir nFirstLineOffset != rFormat.nFirstLineOffset ||
458cdf0e10cSrcweir nAbsLSpace != rFormat.nAbsLSpace ||
459cdf0e10cSrcweir nLSpace != rFormat.nLSpace ||
460cdf0e10cSrcweir nCharTextDistance != rFormat.nCharTextDistance ||
461cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
462cdf0e10cSrcweir meLabelFollowedBy != rFormat.meLabelFollowedBy ||
463cdf0e10cSrcweir mnListtabPos != rFormat.mnListtabPos ||
464cdf0e10cSrcweir mnFirstLineIndent != rFormat.mnFirstLineIndent ||
465cdf0e10cSrcweir mnIndentAt != rFormat.mnIndentAt ||
466cdf0e10cSrcweir // <--
467cdf0e10cSrcweir eVertOrient != rFormat.eVertOrient ||
468cdf0e10cSrcweir sPrefix != rFormat.sPrefix ||
469cdf0e10cSrcweir sSuffix != rFormat.sSuffix ||
470cdf0e10cSrcweir aGraphicSize != rFormat.aGraphicSize ||
471cdf0e10cSrcweir nBulletColor != rFormat.nBulletColor ||
472cdf0e10cSrcweir nBulletRelSize != rFormat.nBulletRelSize ||
473cdf0e10cSrcweir IsShowSymbol() != rFormat.IsShowSymbol() ||
474cdf0e10cSrcweir sCharStyleName != rFormat.sCharStyleName
475cdf0e10cSrcweir )
476cdf0e10cSrcweir return sal_False;
477cdf0e10cSrcweir if (
478cdf0e10cSrcweir (pGraphicBrush && !rFormat.pGraphicBrush) ||
479cdf0e10cSrcweir (!pGraphicBrush && rFormat.pGraphicBrush) ||
480cdf0e10cSrcweir (pGraphicBrush && *pGraphicBrush != *rFormat.pGraphicBrush)
481cdf0e10cSrcweir )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir return sal_False;
484cdf0e10cSrcweir }
485cdf0e10cSrcweir if (
486cdf0e10cSrcweir (pBulletFont && !rFormat.pBulletFont) ||
487cdf0e10cSrcweir (!pBulletFont && rFormat.pBulletFont) ||
488cdf0e10cSrcweir (pBulletFont && *pBulletFont != *rFormat.pBulletFont)
489cdf0e10cSrcweir )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir return sal_False;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir return sal_True;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir /* -----------------28.10.98 09:53-------------------
496cdf0e10cSrcweir *
497cdf0e10cSrcweir * --------------------------------------------------*/
SetGraphicBrush(const SvxBrushItem * pBrushItem,const Size * pSize,const sal_Int16 * pOrient)498cdf0e10cSrcweir void SvxNumberFormat::SetGraphicBrush( const SvxBrushItem* pBrushItem,
499cdf0e10cSrcweir const Size* pSize, const sal_Int16* pOrient)
500cdf0e10cSrcweir {
501cdf0e10cSrcweir if(!pBrushItem)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir delete pGraphicBrush;
504cdf0e10cSrcweir pGraphicBrush = 0;
505cdf0e10cSrcweir }
506cdf0e10cSrcweir else if ( !pGraphicBrush || (pGraphicBrush && !(*pBrushItem == *pGraphicBrush)) )
507cdf0e10cSrcweir {
508cdf0e10cSrcweir delete pGraphicBrush;
509cdf0e10cSrcweir pGraphicBrush = (SvxBrushItem*)pBrushItem->Clone();
510cdf0e10cSrcweir pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
511cdf0e10cSrcweir }
512cdf0e10cSrcweir
513cdf0e10cSrcweir if(pOrient)
514cdf0e10cSrcweir eVertOrient = *pOrient;
515cdf0e10cSrcweir else
516cdf0e10cSrcweir eVertOrient = text::VertOrientation::NONE;
517cdf0e10cSrcweir if(pSize)
518cdf0e10cSrcweir aGraphicSize = *pSize;
519cdf0e10cSrcweir else
520cdf0e10cSrcweir aGraphicSize.Width() = aGraphicSize.Height() = 0;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir /* -----------------28.10.98 09:59-------------------
523cdf0e10cSrcweir *
524cdf0e10cSrcweir * --------------------------------------------------*/
SetGraphic(const String & rName)525cdf0e10cSrcweir void SvxNumberFormat::SetGraphic( const String& rName )
526cdf0e10cSrcweir {
527cdf0e10cSrcweir const String* pName;
528cdf0e10cSrcweir if( pGraphicBrush &&
529cdf0e10cSrcweir 0 != (pName = pGraphicBrush->GetGraphicLink())
530cdf0e10cSrcweir && *pName == rName )
531cdf0e10cSrcweir return ;
532cdf0e10cSrcweir
533cdf0e10cSrcweir delete pGraphicBrush;
534cdf0e10cSrcweir String sTmp;
535cdf0e10cSrcweir pGraphicBrush = new SvxBrushItem( rName, sTmp, GPOS_AREA, 0 );
536cdf0e10cSrcweir pGraphicBrush->SetDoneLink( STATIC_LINK( this, SvxNumberFormat, GraphicArrived) );
537cdf0e10cSrcweir if( eVertOrient == text::VertOrientation::NONE )
538cdf0e10cSrcweir eVertOrient = text::VertOrientation::TOP;
539cdf0e10cSrcweir
540cdf0e10cSrcweir aGraphicSize.Width() = aGraphicSize.Height() = 0;
541cdf0e10cSrcweir }
542cdf0e10cSrcweir /* -----------------------------22.02.01 15:55--------------------------------
543cdf0e10cSrcweir
544cdf0e10cSrcweir ---------------------------------------------------------------------------*/
SetVertOrient(sal_Int16 eSet)545cdf0e10cSrcweir void SvxNumberFormat::SetVertOrient(sal_Int16 eSet)
546cdf0e10cSrcweir {
547cdf0e10cSrcweir eVertOrient = eSet;
548cdf0e10cSrcweir }
549cdf0e10cSrcweir /* -----------------------------22.02.01 15:55--------------------------------
550cdf0e10cSrcweir
551cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetVertOrient() const552cdf0e10cSrcweir sal_Int16 SvxNumberFormat::GetVertOrient() const
553cdf0e10cSrcweir {
554cdf0e10cSrcweir return eVertOrient;
555cdf0e10cSrcweir }
556cdf0e10cSrcweir /* -----------------28.10.98 09:59-------------------
557cdf0e10cSrcweir *
558cdf0e10cSrcweir * --------------------------------------------------*/
SetBulletFont(const Font * pFont)559cdf0e10cSrcweir void SvxNumberFormat::SetBulletFont(const Font* pFont)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir delete pBulletFont;
562cdf0e10cSrcweir pBulletFont = pFont ? new Font(*pFont): 0;
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir // --> OD 2008-01-09 #newlistlevelattrs#
GetPositionAndSpaceMode() const566cdf0e10cSrcweir SvxNumberFormat::SvxNumPositionAndSpaceMode SvxNumberFormat::GetPositionAndSpaceMode() const
567cdf0e10cSrcweir {
568cdf0e10cSrcweir return mePositionAndSpaceMode;
569cdf0e10cSrcweir }
SetPositionAndSpaceMode(SvxNumPositionAndSpaceMode ePositionAndSpaceMode)570cdf0e10cSrcweir void SvxNumberFormat::SetPositionAndSpaceMode( SvxNumPositionAndSpaceMode ePositionAndSpaceMode )
571cdf0e10cSrcweir {
572cdf0e10cSrcweir mePositionAndSpaceMode = ePositionAndSpaceMode;
573cdf0e10cSrcweir }
574cdf0e10cSrcweir
GetLSpace() const575cdf0e10cSrcweir short SvxNumberFormat::GetLSpace() const
576cdf0e10cSrcweir {
577cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
578cdf0e10cSrcweir // DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
579cdf0e10cSrcweir // "<SvxNumberFormat::GetLSpace()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
580cdf0e10cSrcweir //#endif
581cdf0e10cSrcweir return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nLSpace : 0;
582cdf0e10cSrcweir }
GetAbsLSpace() const583cdf0e10cSrcweir short SvxNumberFormat::GetAbsLSpace() const
584cdf0e10cSrcweir {
585cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
586cdf0e10cSrcweir // DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
587cdf0e10cSrcweir // "<SvxNumberFormat::GetAbsLSpace()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
588cdf0e10cSrcweir //#endif
589cdf0e10cSrcweir return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
590cdf0e10cSrcweir ? nAbsLSpace
591cdf0e10cSrcweir : static_cast<short>( GetFirstLineIndent() + GetIndentAt() );
592cdf0e10cSrcweir }
GetFirstLineOffset() const593cdf0e10cSrcweir short SvxNumberFormat::GetFirstLineOffset() const
594cdf0e10cSrcweir {
595cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
596cdf0e10cSrcweir // DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
597cdf0e10cSrcweir // "<SvxNumberFormat::GetFirstLineOffset()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
598cdf0e10cSrcweir //#endif
599cdf0e10cSrcweir return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION
600cdf0e10cSrcweir ? nFirstLineOffset
601cdf0e10cSrcweir : static_cast<short>( GetFirstLineIndent() );
602cdf0e10cSrcweir }
GetCharTextDistance() const603cdf0e10cSrcweir short SvxNumberFormat::GetCharTextDistance() const
604cdf0e10cSrcweir {
605cdf0e10cSrcweir //#if OSL_DEBUG_LEVEL > 1
606cdf0e10cSrcweir // DBG_ASSERT( mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION,
607cdf0e10cSrcweir // "<SvxNumberFormat::GetCharTextDistance()> - misusage: position-and-space-mode does not equal LABEL_WIDTH_AND_POSITION");
608cdf0e10cSrcweir //#endif
609cdf0e10cSrcweir return mePositionAndSpaceMode == LABEL_WIDTH_AND_POSITION ? nCharTextDistance : 0;
610cdf0e10cSrcweir }
611cdf0e10cSrcweir
SetLabelFollowedBy(const SvxNumLabelFollowedBy eLabelFollowedBy)612cdf0e10cSrcweir void SvxNumberFormat::SetLabelFollowedBy( const SvxNumLabelFollowedBy eLabelFollowedBy )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir meLabelFollowedBy = eLabelFollowedBy;
615cdf0e10cSrcweir }
GetLabelFollowedBy() const616cdf0e10cSrcweir SvxNumberFormat::SvxNumLabelFollowedBy SvxNumberFormat::GetLabelFollowedBy() const
617cdf0e10cSrcweir {
618cdf0e10cSrcweir return meLabelFollowedBy;
619cdf0e10cSrcweir }
SetListtabPos(const long nListtabPos)620cdf0e10cSrcweir void SvxNumberFormat::SetListtabPos( const long nListtabPos )
621cdf0e10cSrcweir {
622cdf0e10cSrcweir mnListtabPos = nListtabPos;
623cdf0e10cSrcweir }
GetListtabPos() const624cdf0e10cSrcweir long SvxNumberFormat::GetListtabPos() const
625cdf0e10cSrcweir {
626cdf0e10cSrcweir return mnListtabPos;
627cdf0e10cSrcweir }
SetFirstLineIndent(const long nFirstLineIndent)628cdf0e10cSrcweir void SvxNumberFormat::SetFirstLineIndent( const long nFirstLineIndent )
629cdf0e10cSrcweir {
630cdf0e10cSrcweir mnFirstLineIndent = nFirstLineIndent;
631cdf0e10cSrcweir }
GetFirstLineIndent() const632cdf0e10cSrcweir long SvxNumberFormat::GetFirstLineIndent() const
633cdf0e10cSrcweir {
634cdf0e10cSrcweir return mnFirstLineIndent;
635cdf0e10cSrcweir }
SetIndentAt(const long nIndentAt)636cdf0e10cSrcweir void SvxNumberFormat::SetIndentAt( const long nIndentAt )
637cdf0e10cSrcweir {
638cdf0e10cSrcweir mnIndentAt = nIndentAt;
639cdf0e10cSrcweir }
GetIndentAt() const640cdf0e10cSrcweir long SvxNumberFormat::GetIndentAt() const
641cdf0e10cSrcweir {
642cdf0e10cSrcweir return mnIndentAt;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir // <--
645cdf0e10cSrcweir
646cdf0e10cSrcweir /* -----------------28.10.98 10:03-------------------
647cdf0e10cSrcweir *
648cdf0e10cSrcweir * --------------------------------------------------*/
IMPL_STATIC_LINK(SvxNumberFormat,GraphicArrived,void *,EMPTYARG)649cdf0e10cSrcweir IMPL_STATIC_LINK( SvxNumberFormat, GraphicArrived, void *, EMPTYARG )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir // ggfs. die GrfSize setzen:
652cdf0e10cSrcweir if( !pThis->aGraphicSize.Width() || !pThis->aGraphicSize.Height() )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir const Graphic* pGrf = pThis->pGraphicBrush->GetGraphic();
655cdf0e10cSrcweir if( pGrf )
656cdf0e10cSrcweir pThis->aGraphicSize = SvxNumberFormat::GetGraphicSizeMM100( pGrf );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir pThis->NotifyGraphicArrived();
659cdf0e10cSrcweir return 0;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir /* -----------------------------02.07.01 15:36--------------------------------
662cdf0e10cSrcweir
663cdf0e10cSrcweir ---------------------------------------------------------------------------*/
NotifyGraphicArrived()664cdf0e10cSrcweir void SvxNumberFormat::NotifyGraphicArrived()
665cdf0e10cSrcweir {
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir /* -----------------28.10.98 10:38-------------------
669cdf0e10cSrcweir *
670cdf0e10cSrcweir * --------------------------------------------------*/
GetGraphicSizeMM100(const Graphic * pGraphic)671cdf0e10cSrcweir Size SvxNumberFormat::GetGraphicSizeMM100(const Graphic* pGraphic)
672cdf0e10cSrcweir {
673cdf0e10cSrcweir const MapMode aMapMM100( MAP_100TH_MM );
674cdf0e10cSrcweir const Size& rSize = pGraphic->GetPrefSize();
675cdf0e10cSrcweir Size aRetSize;
676cdf0e10cSrcweir if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir OutputDevice* pOutDev = Application::GetDefaultDevice();
679cdf0e10cSrcweir MapMode aOldMap( pOutDev->GetMapMode() );
680cdf0e10cSrcweir pOutDev->SetMapMode( aMapMM100 );
681cdf0e10cSrcweir aRetSize = pOutDev->PixelToLogic( rSize );
682cdf0e10cSrcweir pOutDev->SetMapMode( aOldMap );
683cdf0e10cSrcweir }
684cdf0e10cSrcweir else
685cdf0e10cSrcweir aRetSize = OutputDevice::LogicToLogic( rSize, pGraphic->GetPrefMapMode(), aMapMM100 );
686cdf0e10cSrcweir return aRetSize;
687cdf0e10cSrcweir }
688cdf0e10cSrcweir /* -----------------28.10.98 15:57-------------------
689cdf0e10cSrcweir *
690cdf0e10cSrcweir * --------------------------------------------------*/
CreateRomanString(sal_uLong nNo,sal_Bool bUpper)691cdf0e10cSrcweir String SvxNumberFormat::CreateRomanString( sal_uLong nNo, sal_Bool bUpper )
692cdf0e10cSrcweir {
693cdf0e10cSrcweir nNo %= 4000; // mehr kann nicht dargestellt werden
694cdf0e10cSrcweir // i, ii, iii, iv, v, vi, vii, vii, viii, ix
695cdf0e10cSrcweir // (Dummy),1000,500,100,50,10,5,1
696cdf0e10cSrcweir const char *cRomanArr = bUpper
697cdf0e10cSrcweir ? "MDCLXVI--" // +2 Dummy-Eintraege !!
698cdf0e10cSrcweir : "mdclxvi--"; // +2 Dummy-Eintraege !!
699cdf0e10cSrcweir
700cdf0e10cSrcweir String sRet;
701cdf0e10cSrcweir sal_uInt16 nMask = 1000;
702cdf0e10cSrcweir while( nMask )
703cdf0e10cSrcweir {
704cdf0e10cSrcweir sal_uInt8 nZahl = sal_uInt8(nNo / nMask);
705cdf0e10cSrcweir sal_uInt8 nDiff = 1;
706cdf0e10cSrcweir nNo %= nMask;
707cdf0e10cSrcweir
708cdf0e10cSrcweir if( 5 < nZahl )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir if( nZahl < 9 )
711cdf0e10cSrcweir sRet += sal_Unicode(*(cRomanArr-1));
712cdf0e10cSrcweir ++nDiff;
713cdf0e10cSrcweir nZahl -= 5;
714cdf0e10cSrcweir }
715cdf0e10cSrcweir switch( nZahl )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir case 3: { sRet += sal_Unicode(*cRomanArr); }
718cdf0e10cSrcweir case 2: { sRet += sal_Unicode(*cRomanArr); }
719cdf0e10cSrcweir case 1: { sRet += sal_Unicode(*cRomanArr); }
720cdf0e10cSrcweir break;
721cdf0e10cSrcweir
722cdf0e10cSrcweir case 4: {
723cdf0e10cSrcweir sRet += sal_Unicode(*cRomanArr);
724cdf0e10cSrcweir sRet += sal_Unicode(*(cRomanArr-nDiff));
725cdf0e10cSrcweir }
726cdf0e10cSrcweir break;
727cdf0e10cSrcweir case 5: { sRet += sal_Unicode(*(cRomanArr-nDiff)); }
728cdf0e10cSrcweir break;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir
731cdf0e10cSrcweir nMask /= 10; // zur naechsten Dekade
732cdf0e10cSrcweir cRomanArr += 2;
733cdf0e10cSrcweir }
734cdf0e10cSrcweir return sRet;
735cdf0e10cSrcweir }
736cdf0e10cSrcweir #ifdef OLD_NUMBER_FORMATTING
GetCharStr(sal_uLong nNo,String & rStr) const737cdf0e10cSrcweir void SvxNumberFormat::GetCharStr( sal_uLong nNo, String& rStr ) const
738cdf0e10cSrcweir {
739cdf0e10cSrcweir DBG_ASSERT( nNo, "0 ist eine ungueltige Nummer !!" );
740cdf0e10cSrcweir
741cdf0e10cSrcweir const sal_uLong coDiff = 'Z' - 'A' +1;
742cdf0e10cSrcweir char cAdd = (SVX_NUM_CHARS_UPPER_LETTER == eNumType ? 'A' : 'a') - 1;
743cdf0e10cSrcweir sal_uLong nCalc;
744cdf0e10cSrcweir
745cdf0e10cSrcweir do {
746cdf0e10cSrcweir nCalc = nNo % coDiff;
747cdf0e10cSrcweir if( !nCalc )
748cdf0e10cSrcweir nCalc = coDiff;
749cdf0e10cSrcweir rStr.Insert( sal_Unicode(cAdd + nCalc ), 0 );
750cdf0e10cSrcweir nNo -= nCalc;
751cdf0e10cSrcweir if( nNo )
752cdf0e10cSrcweir nNo /= coDiff;
753cdf0e10cSrcweir } while( nNo );
754cdf0e10cSrcweir }
755cdf0e10cSrcweir
GetCharStrN(sal_uLong nNo,String & rStr) const756cdf0e10cSrcweir void SvxNumberFormat::GetCharStrN( sal_uLong nNo, String& rStr ) const
757cdf0e10cSrcweir {
758cdf0e10cSrcweir DBG_ASSERT( nNo, "0 ist eine ungueltige Nummer !!" );
759cdf0e10cSrcweir
760cdf0e10cSrcweir const sal_uLong coDiff = 'Z' - 'A' +1;
761cdf0e10cSrcweir char cChar = (char)(--nNo % coDiff);
762cdf0e10cSrcweir if( SVX_NUM_CHARS_UPPER_LETTER_N == eNumType )
763cdf0e10cSrcweir cChar += 'A';
764cdf0e10cSrcweir else
765cdf0e10cSrcweir cChar += 'a';
766cdf0e10cSrcweir
767cdf0e10cSrcweir rStr.Fill( (sal_uInt16)(nNo / coDiff) + 1, sal_Unicode(cChar) );
768cdf0e10cSrcweir }
769cdf0e10cSrcweir #endif //OLD_NUMBER_FORMATTING
770cdf0e10cSrcweir /* -----------------------------22.02.01 13:31--------------------------------
771cdf0e10cSrcweir
772cdf0e10cSrcweir ---------------------------------------------------------------------------*/
GetCharFmtName() const773cdf0e10cSrcweir const String& SvxNumberFormat::GetCharFmtName()const
774cdf0e10cSrcweir {
775cdf0e10cSrcweir return sCharStyleName;
776cdf0e10cSrcweir }
777cdf0e10cSrcweir /* -----------------27.10.98 10:38-------------------
778cdf0e10cSrcweir *
779cdf0e10cSrcweir * --------------------------------------------------*/
780cdf0e10cSrcweir sal_Int32 SvxNumRule::nRefCount = 0;
781cdf0e10cSrcweir static SvxNumberFormat* pStdNumFmt = 0;
782cdf0e10cSrcweir static SvxNumberFormat* pStdOutlineNumFmt = 0;
783cdf0e10cSrcweir // --> OD 2008-02-11 #newlistlevelattrs#
SvxNumRule(sal_uLong nFeatures,sal_uInt16 nLevels,sal_Bool bCont,SvxNumRuleType eType,SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode)784cdf0e10cSrcweir SvxNumRule::SvxNumRule( sal_uLong nFeatures,
785cdf0e10cSrcweir sal_uInt16 nLevels,
786cdf0e10cSrcweir sal_Bool bCont,
787cdf0e10cSrcweir SvxNumRuleType eType,
788cdf0e10cSrcweir SvxNumberFormat::SvxNumPositionAndSpaceMode
789cdf0e10cSrcweir eDefaultNumberFormatPositionAndSpaceMode )
790cdf0e10cSrcweir : nLevelCount(nLevels),
791cdf0e10cSrcweir nFeatureFlags(nFeatures),
792cdf0e10cSrcweir eNumberingType(eType),
793cdf0e10cSrcweir bContinuousNumbering(bCont)
794cdf0e10cSrcweir {
795cdf0e10cSrcweir ++nRefCount;
796cdf0e10cSrcweir LanguageType eLang = Application::GetSettings().GetLanguage();
797cdf0e10cSrcweir aLocale = SvxCreateLocale(eLang);
798cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
799cdf0e10cSrcweir {
800cdf0e10cSrcweir if(i < nLevels)
801cdf0e10cSrcweir {
802cdf0e10cSrcweir aFmts[i] = new SvxNumberFormat(SVX_NUM_CHARS_UPPER_LETTER);
803cdf0e10cSrcweir //daran wird zwischen writer und draw unterschieden
804cdf0e10cSrcweir if(nFeatures & NUM_CONTINUOUS)
805cdf0e10cSrcweir {
806cdf0e10cSrcweir // --> OD 2008-02-11 #newlistlevelattrs#
807cdf0e10cSrcweir if ( eDefaultNumberFormatPositionAndSpaceMode ==
808cdf0e10cSrcweir SvxNumberFormat::LABEL_WIDTH_AND_POSITION )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir aFmts[i]->SetLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE) );
811cdf0e10cSrcweir aFmts[i]->SetAbsLSpace( MM100_TO_TWIP(DEF_WRITER_LSPACE * (i+1)) );
812cdf0e10cSrcweir aFmts[i]->SetFirstLineOffset(MM100_TO_TWIP(-DEF_WRITER_LSPACE));
813cdf0e10cSrcweir }
814cdf0e10cSrcweir else if ( eDefaultNumberFormatPositionAndSpaceMode ==
815cdf0e10cSrcweir SvxNumberFormat::LABEL_ALIGNMENT )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir // first line indent of general numbering in inch: -0,25 inch
818cdf0e10cSrcweir const long cFirstLineIndent = -1440/4;
819cdf0e10cSrcweir // indent values of general numbering in inch:
820cdf0e10cSrcweir // 0,5 0,75 1,0 1,25 1,5
821cdf0e10cSrcweir // 1,75 2,0 2,25 2,5 2,75
822cdf0e10cSrcweir const long cIndentAt = 1440/4;
823cdf0e10cSrcweir aFmts[i]->SetPositionAndSpaceMode( SvxNumberFormat::LABEL_ALIGNMENT );
824cdf0e10cSrcweir aFmts[i]->SetLabelFollowedBy( SvxNumberFormat::LISTTAB );
825cdf0e10cSrcweir aFmts[i]->SetListtabPos( cIndentAt * (i+2) );
826cdf0e10cSrcweir aFmts[i]->SetFirstLineIndent( cFirstLineIndent );
827cdf0e10cSrcweir aFmts[i]->SetIndentAt( cIndentAt * (i+2) );
828cdf0e10cSrcweir }
829cdf0e10cSrcweir // <--
830cdf0e10cSrcweir }
831cdf0e10cSrcweir else
832cdf0e10cSrcweir {
833cdf0e10cSrcweir aFmts[i]->SetLSpace( DEF_DRAW_LSPACE );
834cdf0e10cSrcweir aFmts[i]->SetAbsLSpace( DEF_DRAW_LSPACE * (i) );
835cdf0e10cSrcweir }
836cdf0e10cSrcweir }
837cdf0e10cSrcweir else
838cdf0e10cSrcweir aFmts[i] = 0;
839cdf0e10cSrcweir aFmtsSet[i] = sal_False;
840cdf0e10cSrcweir }
841cdf0e10cSrcweir }
842cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
843cdf0e10cSrcweir *
844cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumRule(const SvxNumRule & rCopy)845cdf0e10cSrcweir SvxNumRule::SvxNumRule(const SvxNumRule& rCopy)
846cdf0e10cSrcweir {
847cdf0e10cSrcweir ++nRefCount;
848cdf0e10cSrcweir aLocale = rCopy.aLocale;
849cdf0e10cSrcweir nLevelCount = rCopy.nLevelCount ;
850cdf0e10cSrcweir nFeatureFlags = rCopy.nFeatureFlags ;
851cdf0e10cSrcweir bContinuousNumbering = rCopy.bContinuousNumbering;
852cdf0e10cSrcweir eNumberingType = rCopy.eNumberingType;
853cdf0e10cSrcweir memset( aFmts, 0, sizeof( aFmts ));
854cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
855cdf0e10cSrcweir {
856cdf0e10cSrcweir if(rCopy.aFmts[i])
857cdf0e10cSrcweir aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
858cdf0e10cSrcweir else
859cdf0e10cSrcweir aFmts[i] = 0;
860cdf0e10cSrcweir aFmtsSet[i] = rCopy.aFmtsSet[i];
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir /* -----------------08.12.98 11:07-------------------
864cdf0e10cSrcweir *
865cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumRule(SvStream & rStream)866cdf0e10cSrcweir SvxNumRule::SvxNumRule(SvStream &rStream)
867cdf0e10cSrcweir {
868cdf0e10cSrcweir ++nRefCount;
869cdf0e10cSrcweir LanguageType eLang = Application::GetSettings().GetLanguage();
870cdf0e10cSrcweir aLocale = SvxCreateLocale(eLang);
871cdf0e10cSrcweir sal_uInt16 nVersion;
872cdf0e10cSrcweir sal_uInt16 nTemp;
873cdf0e10cSrcweir rStream >> nVersion;
874cdf0e10cSrcweir rStream >> nLevelCount;
875cdf0e10cSrcweir rStream >> nTemp;
876cdf0e10cSrcweir nFeatureFlags = nTemp;
877cdf0e10cSrcweir rStream >> nTemp;
878cdf0e10cSrcweir bContinuousNumbering = (sal_Bool)nTemp;
879cdf0e10cSrcweir rStream >> nTemp;
880cdf0e10cSrcweir eNumberingType = (SvxNumRuleType)nTemp;
881cdf0e10cSrcweir memset( aFmts, 0, sizeof( aFmts ));
882cdf0e10cSrcweir
883cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
884cdf0e10cSrcweir {
885cdf0e10cSrcweir sal_uInt16 nSet;
886cdf0e10cSrcweir rStream >> nSet;
887cdf0e10cSrcweir if(nSet)
888cdf0e10cSrcweir aFmts[i] = new SvxNumberFormat(rStream);
889cdf0e10cSrcweir else
890cdf0e10cSrcweir aFmts[i] = 0;
891cdf0e10cSrcweir aFmtsSet[i] = aFmts[i] ? sal_True : sal_False;
892cdf0e10cSrcweir }
893cdf0e10cSrcweir if(NUMITEM_VERSION_02 <= nVersion)
894cdf0e10cSrcweir {
895cdf0e10cSrcweir sal_uInt16 nShort;
896cdf0e10cSrcweir rStream >> nShort;
897cdf0e10cSrcweir nFeatureFlags = nShort;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir }
900cdf0e10cSrcweir
901cdf0e10cSrcweir /* -----------------08.12.98 11:07-------------------
902cdf0e10cSrcweir *
903cdf0e10cSrcweir * --------------------------------------------------*/
Store(SvStream & rStream)904cdf0e10cSrcweir SvStream& SvxNumRule::Store(SvStream &rStream)
905cdf0e10cSrcweir {
906cdf0e10cSrcweir rStream<<(sal_uInt16)NUMITEM_VERSION_03;
907cdf0e10cSrcweir rStream<<nLevelCount;
908cdf0e10cSrcweir //first save of nFeatureFlags for old versions
909cdf0e10cSrcweir rStream<<(sal_uInt16)nFeatureFlags;
910cdf0e10cSrcweir rStream<<(sal_uInt16)bContinuousNumbering;
911cdf0e10cSrcweir rStream<<(sal_uInt16)eNumberingType;
912cdf0e10cSrcweir
913cdf0e10cSrcweir FontToSubsFontConverter pConverter = 0;
914cdf0e10cSrcweir sal_Bool bConvertBulletFont = rStream.GetVersion() <= SOFFICE_FILEFORMAT_50;
915cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
916cdf0e10cSrcweir {
917cdf0e10cSrcweir if(aFmts[i])
918cdf0e10cSrcweir {
919cdf0e10cSrcweir rStream << sal_uInt16(1);
920cdf0e10cSrcweir if(bConvertBulletFont && aFmts[i]->GetBulletFont())
921cdf0e10cSrcweir {
922cdf0e10cSrcweir if(!pConverter)
923cdf0e10cSrcweir pConverter =
924cdf0e10cSrcweir CreateFontToSubsFontConverter(aFmts[i]->GetBulletFont()->GetName(),
925cdf0e10cSrcweir FONTTOSUBSFONT_EXPORT|FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS);
926cdf0e10cSrcweir }
927cdf0e10cSrcweir aFmts[i]->Store(rStream, pConverter);
928cdf0e10cSrcweir }
929cdf0e10cSrcweir else
930cdf0e10cSrcweir rStream << sal_uInt16(0);
931cdf0e10cSrcweir }
932cdf0e10cSrcweir //second save of nFeatureFlags for new versions
933cdf0e10cSrcweir rStream<<(sal_uInt16)nFeatureFlags;
934cdf0e10cSrcweir if(pConverter)
935cdf0e10cSrcweir DestroyFontToSubsFontConverter(pConverter);
936cdf0e10cSrcweir
937cdf0e10cSrcweir return rStream;
938cdf0e10cSrcweir }
939cdf0e10cSrcweir
940cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
941cdf0e10cSrcweir *
942cdf0e10cSrcweir * --------------------------------------------------*/
~SvxNumRule()943cdf0e10cSrcweir SvxNumRule::~SvxNumRule()
944cdf0e10cSrcweir {
945cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
946cdf0e10cSrcweir delete aFmts[i];
947cdf0e10cSrcweir if(!--nRefCount)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir DELETEZ(pStdNumFmt);
950cdf0e10cSrcweir DELETEZ(pStdOutlineNumFmt);
951cdf0e10cSrcweir }
952cdf0e10cSrcweir }
953cdf0e10cSrcweir /* -----------------29.10.98 16:07-------------------
954cdf0e10cSrcweir *
955cdf0e10cSrcweir * --------------------------------------------------*/
operator =(const SvxNumRule & rCopy)956cdf0e10cSrcweir SvxNumRule& SvxNumRule::operator=( const SvxNumRule& rCopy )
957cdf0e10cSrcweir {
958cdf0e10cSrcweir nLevelCount = rCopy.nLevelCount;
959cdf0e10cSrcweir nFeatureFlags = rCopy.nFeatureFlags;
960cdf0e10cSrcweir bContinuousNumbering = rCopy.bContinuousNumbering;
961cdf0e10cSrcweir eNumberingType = rCopy.eNumberingType;
962cdf0e10cSrcweir for(sal_uInt16 i = 0; i < SVX_MAX_NUM; i++)
963cdf0e10cSrcweir {
964cdf0e10cSrcweir delete aFmts[i];
965cdf0e10cSrcweir if(rCopy.aFmts[i])
966cdf0e10cSrcweir aFmts[i] = new SvxNumberFormat(*rCopy.aFmts[i]);
967cdf0e10cSrcweir else
968cdf0e10cSrcweir aFmts[i] = 0;
969cdf0e10cSrcweir aFmtsSet[i] = rCopy.aFmtsSet[i];
970cdf0e10cSrcweir }
971cdf0e10cSrcweir return *this;
972cdf0e10cSrcweir }
973cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
974cdf0e10cSrcweir *
975cdf0e10cSrcweir * --------------------------------------------------*/
operator ==(const SvxNumRule & rCopy) const976cdf0e10cSrcweir int SvxNumRule::operator==( const SvxNumRule& rCopy) const
977cdf0e10cSrcweir {
978cdf0e10cSrcweir if(nLevelCount != rCopy.nLevelCount ||
979cdf0e10cSrcweir nFeatureFlags != rCopy.nFeatureFlags ||
980cdf0e10cSrcweir bContinuousNumbering != rCopy.bContinuousNumbering ||
981cdf0e10cSrcweir eNumberingType != rCopy.eNumberingType)
982cdf0e10cSrcweir return sal_False;
983cdf0e10cSrcweir for(sal_uInt16 i = 0; i < nLevelCount; i++)
984cdf0e10cSrcweir {
985cdf0e10cSrcweir if (
986cdf0e10cSrcweir (aFmtsSet[i] != rCopy.aFmtsSet[i]) ||
987cdf0e10cSrcweir (!aFmts[i] && rCopy.aFmts[i]) ||
988cdf0e10cSrcweir (aFmts[i] && !rCopy.aFmts[i]) ||
989cdf0e10cSrcweir (aFmts[i] && *aFmts[i] != *rCopy.aFmts[i])
990cdf0e10cSrcweir )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir return sal_False;
993cdf0e10cSrcweir }
994cdf0e10cSrcweir }
995cdf0e10cSrcweir return sal_True;
996cdf0e10cSrcweir }
997cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
998cdf0e10cSrcweir *
999cdf0e10cSrcweir * --------------------------------------------------*/
Get(sal_uInt16 nLevel) const1000cdf0e10cSrcweir const SvxNumberFormat* SvxNumRule::Get(sal_uInt16 nLevel)const
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1003cdf0e10cSrcweir if( nLevel < SVX_MAX_NUM )
1004cdf0e10cSrcweir return aFmtsSet[nLevel] ? aFmts[nLevel] : 0;
1005cdf0e10cSrcweir else
1006cdf0e10cSrcweir return 0;
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir /* -----------------02.11.98 09:10-------------------
1009cdf0e10cSrcweir *
1010cdf0e10cSrcweir * --------------------------------------------------*/
GetLevel(sal_uInt16 nLevel) const1011cdf0e10cSrcweir const SvxNumberFormat& SvxNumRule::GetLevel(sal_uInt16 nLevel)const
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir if(!pStdNumFmt)
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir pStdNumFmt = new SvxNumberFormat(SVX_NUM_ARABIC);
1016cdf0e10cSrcweir pStdOutlineNumFmt = new SvxNumberFormat(SVX_NUM_NUMBER_NONE);
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir
1019cdf0e10cSrcweir DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1020cdf0e10cSrcweir
1021cdf0e10cSrcweir return ( ( nLevel < SVX_MAX_NUM ) && aFmts[nLevel] ) ?
1022cdf0e10cSrcweir *aFmts[nLevel] : eNumberingType == SVX_RULETYPE_NUMBERING ?
1023cdf0e10cSrcweir *pStdNumFmt : *pStdOutlineNumFmt;
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir /* -----------------29.10.98 09:08-------------------
1027cdf0e10cSrcweir *
1028cdf0e10cSrcweir * --------------------------------------------------*/
SetLevel(sal_uInt16 i,const SvxNumberFormat & rNumFmt,sal_Bool bIsValid)1029cdf0e10cSrcweir void SvxNumRule::SetLevel( sal_uInt16 i, const SvxNumberFormat& rNumFmt, sal_Bool bIsValid )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir DBG_ASSERT(i < SVX_MAX_NUM, "falsches Level" );
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir if( (i < SVX_MAX_NUM) && (!aFmtsSet[i] || !(rNumFmt == *Get( i ))) )
1034cdf0e10cSrcweir {
1035cdf0e10cSrcweir delete aFmts[ i ];
1036cdf0e10cSrcweir aFmts[ i ] = new SvxNumberFormat( rNumFmt );
1037cdf0e10cSrcweir aFmtsSet[i] = bIsValid;
1038cdf0e10cSrcweir // bInvalidRuleFlag = sal_True;
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir /* -----------------30.10.98 12:44-------------------
1042cdf0e10cSrcweir *
1043cdf0e10cSrcweir * --------------------------------------------------*/
SetLevel(sal_uInt16 nLevel,const SvxNumberFormat * pFmt)1044cdf0e10cSrcweir void SvxNumRule::SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt)
1045cdf0e10cSrcweir {
1046cdf0e10cSrcweir DBG_ASSERT(nLevel < SVX_MAX_NUM, "falsches Level" );
1047cdf0e10cSrcweir
1048cdf0e10cSrcweir if( nLevel < SVX_MAX_NUM )
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir aFmtsSet[nLevel] = 0 != pFmt;
1051cdf0e10cSrcweir if(pFmt)
1052cdf0e10cSrcweir SetLevel(nLevel, *pFmt);
1053cdf0e10cSrcweir else
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir delete aFmts[nLevel];
1056cdf0e10cSrcweir aFmts[nLevel] = 0;
1057cdf0e10cSrcweir }
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir /* -----------------28.10.98 15:38-------------------
1061cdf0e10cSrcweir *
1062cdf0e10cSrcweir * --------------------------------------------------*/
MakeNumString(const SvxNodeNum & rNum,sal_Bool bInclStrings) const1063cdf0e10cSrcweir String SvxNumRule::MakeNumString( const SvxNodeNum& rNum, sal_Bool bInclStrings ) const
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir String aStr;
1066cdf0e10cSrcweir if( SVX_NO_NUM > rNum.GetLevel() && !( SVX_NO_NUMLEVEL & rNum.GetLevel() ) )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir const SvxNumberFormat& rMyNFmt = GetLevel( rNum.GetLevel() );
1069cdf0e10cSrcweir if( SVX_NUM_NUMBER_NONE != rMyNFmt.GetNumberingType() )
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir sal_uInt8 i = rNum.GetLevel();
1072cdf0e10cSrcweir
1073cdf0e10cSrcweir if( !IsContinuousNumbering() &&
1074cdf0e10cSrcweir 1 < rMyNFmt.GetIncludeUpperLevels() ) // nur der eigene Level ?
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir sal_uInt8 n = rMyNFmt.GetIncludeUpperLevels();
1077cdf0e10cSrcweir if( 1 < n )
1078cdf0e10cSrcweir {
1079cdf0e10cSrcweir if( i+1 >= n )
1080cdf0e10cSrcweir i -= n - 1;
1081cdf0e10cSrcweir else
1082cdf0e10cSrcweir i = 0;
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir }
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir for( ; i <= rNum.GetLevel(); ++i )
1087cdf0e10cSrcweir {
1088cdf0e10cSrcweir const SvxNumberFormat& rNFmt = GetLevel( i );
1089cdf0e10cSrcweir if( SVX_NUM_NUMBER_NONE == rNFmt.GetNumberingType() )
1090cdf0e10cSrcweir {
1091cdf0e10cSrcweir // Soll aus 1.1.1 --> 2. NoNum --> 1..1 oder 1.1 ??
1092cdf0e10cSrcweir // if( i != rNum.nMyLevel )
1093cdf0e10cSrcweir // aStr += aDotStr;
1094cdf0e10cSrcweir continue;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir
1097cdf0e10cSrcweir sal_Bool bDot = sal_True;
1098cdf0e10cSrcweir if( rNum.GetLevelVal()[ i ] )
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir if(SVX_NUM_BITMAP != rNFmt.GetNumberingType())
1101cdf0e10cSrcweir aStr += rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], aLocale );
1102cdf0e10cSrcweir else
1103cdf0e10cSrcweir bDot = sal_False;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir else
1106cdf0e10cSrcweir aStr += sal_Unicode('0'); // alle 0-Level sind eine 0
1107cdf0e10cSrcweir if( i != rNum.GetLevel() && bDot)
1108cdf0e10cSrcweir aStr += sal_Unicode('.');
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir if( bInclStrings )
1113cdf0e10cSrcweir {
1114cdf0e10cSrcweir aStr.Insert( rMyNFmt.GetPrefix(), 0 );
1115cdf0e10cSrcweir aStr += rMyNFmt.GetSuffix();
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir }
1118cdf0e10cSrcweir return aStr;
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir /* -----------------18.08.99 10:18-------------------
1121cdf0e10cSrcweir Description: changes linked to embedded bitmaps
1122cdf0e10cSrcweir --------------------------------------------------*/
UnLinkGraphics()1123cdf0e10cSrcweir sal_Bool SvxNumRule::UnLinkGraphics()
1124cdf0e10cSrcweir {
1125cdf0e10cSrcweir sal_Bool bRet = sal_False;
1126cdf0e10cSrcweir for(sal_uInt16 i = 0; i < GetLevelCount(); i++)
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir SvxNumberFormat aFmt(GetLevel(i));
1129cdf0e10cSrcweir const SvxBrushItem* pBrush = aFmt.GetBrush();
1130cdf0e10cSrcweir const String* pLinkStr;
1131cdf0e10cSrcweir const Graphic* pGraphic;
1132cdf0e10cSrcweir if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir if(pBrush &&
1135cdf0e10cSrcweir 0 != (pLinkStr = pBrush->GetGraphicLink()) &&
1136cdf0e10cSrcweir pLinkStr->Len() &&
1137cdf0e10cSrcweir 0 !=(pGraphic = pBrush->GetGraphic()))
1138cdf0e10cSrcweir {
1139cdf0e10cSrcweir SvxBrushItem aTempItem(*pBrush);
1140cdf0e10cSrcweir aTempItem.SetGraphicLink( String());
1141cdf0e10cSrcweir aTempItem.SetGraphic(*pGraphic);
1142cdf0e10cSrcweir sal_Int16 eOrient = aFmt.GetVertOrient();
1143cdf0e10cSrcweir aFmt.SetGraphicBrush( &aTempItem, &aFmt.GetGraphicSize(), &eOrient );
1144cdf0e10cSrcweir bRet = sal_True;
1145cdf0e10cSrcweir }
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir else if((SVX_NUM_BITMAP|LINK_TOKEN) == aFmt.GetNumberingType())
1148cdf0e10cSrcweir aFmt.SetNumberingType(SVX_NUM_BITMAP);
1149cdf0e10cSrcweir SetLevel(i, aFmt);
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir return bRet;
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir
1154cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
1155cdf0e10cSrcweir *
1156cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumBulletItem(SvxNumRule & rRule)1157cdf0e10cSrcweir SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule) :
1158cdf0e10cSrcweir SfxPoolItem(SID_ATTR_NUMBERING_RULE),
1159cdf0e10cSrcweir pNumRule(new SvxNumRule(rRule))
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir }
1162cdf0e10cSrcweir
1163cdf0e10cSrcweir /*-----------------23.11.98 10:36-------------------
1164cdf0e10cSrcweir MT: Das sind ja sehr sinnige Kommentare...
1165cdf0e10cSrcweir --------------------------------------------------*/
SvxNumBulletItem(SvxNumRule & rRule,sal_uInt16 _nWhich)1166cdf0e10cSrcweir SvxNumBulletItem::SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 _nWhich ) :
1167cdf0e10cSrcweir SfxPoolItem(_nWhich),
1168cdf0e10cSrcweir pNumRule(new SvxNumRule(rRule))
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir
Create(SvStream & s,sal_uInt16 n) const1172cdf0e10cSrcweir SfxPoolItem* SvxNumBulletItem::Create(SvStream &s, sal_uInt16 n) const
1173cdf0e10cSrcweir {
1174cdf0e10cSrcweir return SfxPoolItem::Create(s, n );
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir
1177cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
1178cdf0e10cSrcweir *
1179cdf0e10cSrcweir * --------------------------------------------------*/
SvxNumBulletItem(const SvxNumBulletItem & rCopy)1180cdf0e10cSrcweir SvxNumBulletItem::SvxNumBulletItem(const SvxNumBulletItem& rCopy) :
1181cdf0e10cSrcweir SfxPoolItem(rCopy.Which())
1182cdf0e10cSrcweir {
1183cdf0e10cSrcweir pNumRule = new SvxNumRule(*rCopy.pNumRule);
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
1186cdf0e10cSrcweir *
1187cdf0e10cSrcweir * --------------------------------------------------*/
~SvxNumBulletItem()1188cdf0e10cSrcweir SvxNumBulletItem::~SvxNumBulletItem()
1189cdf0e10cSrcweir {
1190cdf0e10cSrcweir delete pNumRule;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir
1193cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
1194cdf0e10cSrcweir *
1195cdf0e10cSrcweir * --------------------------------------------------*/
operator ==(const SfxPoolItem & rCopy) const1196cdf0e10cSrcweir int SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir return *pNumRule == *((SvxNumBulletItem&)rCopy).pNumRule;
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir /* -----------------27.10.98 10:41-------------------
1201cdf0e10cSrcweir *
1202cdf0e10cSrcweir * --------------------------------------------------*/
Clone(SfxItemPool *) const1203cdf0e10cSrcweir SfxPoolItem* SvxNumBulletItem::Clone( SfxItemPool * ) const
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir return new SvxNumBulletItem(*this);
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir /* -----------------08.12.98 10:43-------------------
1208cdf0e10cSrcweir *
1209cdf0e10cSrcweir * --------------------------------------------------*/
GetVersion(sal_uInt16) const1210cdf0e10cSrcweir sal_uInt16 SvxNumBulletItem::GetVersion( sal_uInt16 /*nFileVersion*/ ) const
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir return NUMITEM_VERSION_03;
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir /* -----------------08.12.98 10:43-------------------
1215cdf0e10cSrcweir *
1216cdf0e10cSrcweir * --------------------------------------------------*/
Store(SvStream & rStream,sal_uInt16) const1217cdf0e10cSrcweir SvStream& SvxNumBulletItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion*/ )const
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir pNumRule->Store(rStream);
1220cdf0e10cSrcweir return rStream;
1221cdf0e10cSrcweir }
1222cdf0e10cSrcweir
1223cdf0e10cSrcweir /* -----------------08.12.98 10:43-------------------
1224cdf0e10cSrcweir *
1225cdf0e10cSrcweir * --------------------------------------------------*/
1226cdf0e10cSrcweir
QueryValue(com::sun::star::uno::Any & rVal,sal_uInt8) const1227cdf0e10cSrcweir sal_Bool SvxNumBulletItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
1228cdf0e10cSrcweir {
1229cdf0e10cSrcweir rVal <<= SvxCreateNumRule( pNumRule );
1230cdf0e10cSrcweir return sal_True;
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir
PutValue(const com::sun::star::uno::Any & rVal,sal_uInt8)1233cdf0e10cSrcweir sal_Bool SvxNumBulletItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir uno::Reference< container::XIndexReplace > xRule;
1236cdf0e10cSrcweir if( rVal >>= xRule )
1237cdf0e10cSrcweir {
1238cdf0e10cSrcweir try
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir SvxNumRule* pNewRule = new SvxNumRule( SvxGetNumRule( xRule ) );
1241cdf0e10cSrcweir if( pNewRule->GetLevelCount() != pNumRule->GetLevelCount() ||
1242cdf0e10cSrcweir pNewRule->GetNumRuleType() != pNumRule->GetNumRuleType() )
1243cdf0e10cSrcweir {
1244cdf0e10cSrcweir SvxNumRule* pConverted = SvxConvertNumRule( pNewRule, pNumRule->GetLevelCount(), pNumRule->GetNumRuleType() );
1245cdf0e10cSrcweir delete pNewRule;
1246cdf0e10cSrcweir pNewRule = pConverted;
1247cdf0e10cSrcweir }
1248cdf0e10cSrcweir delete pNumRule;
1249cdf0e10cSrcweir pNumRule = pNewRule;
1250cdf0e10cSrcweir return sal_True;
1251cdf0e10cSrcweir }
1252cdf0e10cSrcweir catch(lang::IllegalArgumentException&)
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir return sal_False;
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir
1259cdf0e10cSrcweir /* -----------------08.12.98 10:43-------------------
1260cdf0e10cSrcweir *
1261cdf0e10cSrcweir * --------------------------------------------------*/
SvxConvertNumRule(const SvxNumRule * pRule,sal_uInt16 nLevels,SvxNumRuleType eType)1262cdf0e10cSrcweir SvxNumRule* SvxConvertNumRule( const SvxNumRule* pRule, sal_uInt16 nLevels, SvxNumRuleType eType )
1263cdf0e10cSrcweir {
1264cdf0e10cSrcweir const sal_uInt16 nSrcLevels = pRule->GetLevelCount();
1265cdf0e10cSrcweir SvxNumRule* pNewRule = new SvxNumRule( pRule->GetFeatureFlags(), nLevels, pRule->IsContinuousNumbering(), eType );
1266cdf0e10cSrcweir
1267cdf0e10cSrcweir for( sal_uInt16 nLevel = 0; (nLevel < nLevels) && (nLevel < nSrcLevels); nLevel++ )
1268cdf0e10cSrcweir pNewRule->SetLevel( nLevel, pRule->GetLevel( nLevel ) );
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir return pNewRule;
1271cdf0e10cSrcweir }
1272