Bump version to 24.04.3.4
[LibreOffice.git] / editeng / source / items / legacyitem.cxx
blob96742f46fcaea7b71dcee909ded678e45e345af7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <editeng/legacyitem.hxx>
21 #include <unotools/fontdefs.hxx>
22 #include <tools/tenccvt.hxx>
23 #include <tools/stream.hxx>
24 #include <comphelper/fileformat.h>
25 #include <vcl/graph.hxx>
26 #include <vcl/GraphicObject.hxx>
27 #include <vcl/TypeSerializer.hxx>
28 #include <osl/diagnose.h>
29 #include <tools/urlobj.hxx>
30 #include <editeng/fontitem.hxx>
31 #include <editeng/fhgtitem.hxx>
32 #include <editeng/wghtitem.hxx>
33 #include <editeng/postitem.hxx>
34 #include <editeng/udlnitem.hxx>
35 #include <editeng/crossedoutitem.hxx>
36 #include <editeng/colritem.hxx>
37 #include <editeng/boxitem.hxx>
38 #include <editeng/borderline.hxx>
39 #include <editeng/lineitem.hxx>
40 #include <editeng/brushitem.hxx>
41 #include <editeng/editerr.hxx>
42 #include <editeng/adjustitem.hxx>
43 #include <editeng/justifyitem.hxx>
44 #include <editeng/frmdiritem.hxx>
45 #include <editeng/formatbreakitem.hxx>
46 #include <editeng/keepitem.hxx>
47 #include <editeng/shaditem.hxx>
48 #include <tools/GenericTypeSerializer.hxx>
51 void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP)
53 rItem.legacy_direct_set(nH, nP, eP);
56 namespace legacy
58 namespace SvxFont
60 sal_uInt16 GetVersion(sal_uInt16)
62 return 0;
65 void Create(SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
67 sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
68 OUString aName, aStyle;
69 rStrm.ReadUChar( _eFamily );
70 rStrm.ReadUChar( eFontPitch );
71 rStrm.ReadUChar( eFontTextEncoding );
73 // UNICODE: rStrm >> aName;
74 aName = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
76 // UNICODE: rStrm >> aStyle;
77 aStyle = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
79 // Set the "correct" textencoding
80 eFontTextEncoding = static_cast<sal_uInt8>(GetSOLoadTextEncoding( eFontTextEncoding ));
82 // at some point, the StarBats changes from ANSI font to SYMBOL font
83 if ( RTL_TEXTENCODING_SYMBOL != eFontTextEncoding && aName == "StarBats" )
84 eFontTextEncoding = RTL_TEXTENCODING_SYMBOL;
86 // Check if we have stored unicode
87 sal_uInt64 const nStreamPos = rStrm.Tell();
88 // #define STORE_UNICODE_MAGIC_MARKER 0xFE331188
89 sal_uInt32 nMagic = 0xFE331188;
90 rStrm.ReadUInt32( nMagic );
91 if ( nMagic == 0xFE331188 )
93 aName = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
94 aStyle = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
96 else
98 rStrm.Seek( nStreamPos );
101 rItem.SetFamilyName(aName);
102 rItem.SetStyleName(aStyle);
103 rItem.SetFamily(static_cast<FontFamily>(_eFamily));
104 rItem.SetPitch(static_cast<FontPitch>(eFontPitch));
105 rItem.SetCharSet(static_cast<rtl_TextEncoding>(eFontTextEncoding));
108 SvStream& Store(const SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
110 const bool bToBats(IsOpenSymbol(rItem.GetFamilyName()));
112 rStrm.WriteUChar(rItem.GetFamily()).WriteUChar(rItem.GetPitch()).WriteUChar(bToBats ?
113 RTL_TEXTENCODING_SYMBOL :
114 GetSOStoreTextEncoding(rItem.GetCharSet()));
116 const OUString aStoreFamilyName(bToBats ? "StarBats" : rItem.GetFamilyName());
118 rStrm.WriteUniOrByteString(aStoreFamilyName, rStrm.GetStreamCharSet());
119 rStrm.WriteUniOrByteString(rItem.GetStyleName(), rStrm.GetStreamCharSet());
121 return rStrm;
125 namespace SvxFontHeight
127 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
129 return (nFileFormatVersion <= SOFFICE_FILEFORMAT_40)
130 ? FONTHEIGHT_16_VERSION
131 : FONTHEIGHT_UNIT_VERSION;
134 void Create(SvxFontHeightItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
136 sal_uInt16 nsize, nprop = 0;
137 MapUnit nPropUnit = MapUnit::MapRelative;
139 rStrm.ReadUInt16( nsize );
141 if( FONTHEIGHT_16_VERSION <= nItemVersion )
142 rStrm.ReadUInt16( nprop );
143 else
145 sal_uInt8 nP;
146 rStrm .ReadUChar( nP );
147 nprop = static_cast<sal_uInt16>(nP);
150 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
152 sal_uInt16 nTmp;
153 rStrm.ReadUInt16( nTmp );
154 nPropUnit = static_cast<MapUnit>(nTmp);
157 Create_legacy_direct_set(rItem, nsize, nprop, nPropUnit);
160 SvStream& Store(const SvxFontHeightItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
162 rStrm.WriteUInt16( rItem.GetHeight() );
164 if( FONTHEIGHT_UNIT_VERSION <= nItemVersion )
165 rStrm.WriteUInt16( rItem.GetProp() ).WriteUInt16( static_cast<sal_uInt16>(rItem.GetPropUnit()) );
166 else
168 // When exporting to the old versions the relative information is lost
169 // when there is no percentage
170 sal_uInt16 _nProp = rItem.GetProp();
171 if( MapUnit::MapRelative != rItem.GetPropUnit() )
172 _nProp = 100;
173 rStrm.WriteUInt16( _nProp );
175 return rStrm;
179 namespace SvxWeight
181 sal_uInt16 GetVersion(sal_uInt16)
183 return 0;
186 void Create(SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
188 sal_uInt8 nWeight(0);
189 rStrm.ReadUChar(nWeight);
190 rItem.SetValue(static_cast<FontWeight>(nWeight));
193 SvStream& Store(const SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
195 rStrm.WriteUChar(rItem.GetValue());
196 return rStrm;
200 namespace SvxPosture
202 sal_uInt16 GetVersion(sal_uInt16)
204 return 0;
207 void Create(SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
209 sal_uInt8 nPosture(0);
210 rStrm.ReadUChar(nPosture);
211 rItem.SetValue(static_cast<FontItalic>(nPosture));
214 SvStream& Store(const SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
216 rStrm.WriteUChar( rItem.GetValue() );
217 return rStrm;
221 namespace SvxTextLine // SvxUnderlineItem, SvxOverlineItem -> SvxTextLineItem
223 sal_uInt16 GetVersion(sal_uInt16)
225 return 0;
228 void Create(SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
230 sal_uInt8 nState(0);
231 rStrm.ReadUChar(nState);
232 rItem.SetValue(static_cast<FontLineStyle>(nState));
233 // GetColor() is *not* saved/loaded ?!?
236 SvStream& Store(const SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
238 rStrm.WriteUChar(rItem.GetValue());
239 // GetColor() is *not* saved/loaded ?!?
240 return rStrm;
244 namespace SvxCrossedOut
246 sal_uInt16 GetVersion(sal_uInt16)
248 return 0;
251 void Create(SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
253 sal_uInt8 eCross(0);
254 rStrm.ReadUChar(eCross);
255 rItem.SetValue(static_cast<FontStrikeout>(eCross));
258 SvStream& Store(const SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
260 rStrm.WriteUChar(rItem.GetValue());
261 return rStrm;
265 namespace SvxColor
267 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
269 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
270 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
271 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
272 "SvxColorItem: Is there a new file format? ");
273 return SOFFICE_FILEFORMAT_50 >= nFileFormatVersion ? VERSION_USEAUTOCOLOR : 0;
276 void Create(SvxColorItem& rItem, SvStream& rStrm, sal_uInt16)
278 Color aColor(COL_AUTO);
279 tools::GenericTypeSerializer aSerializer(rStrm);
280 aSerializer.readColor(aColor);
281 rItem.SetValue(aColor);
284 SvStream& Store(const SvxColorItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
286 tools::GenericTypeSerializer aSerializer(rStrm);
287 if( VERSION_USEAUTOCOLOR == nItemVersion && COL_AUTO == rItem.GetValue() )
288 aSerializer.writeColor(COL_BLACK);
289 else
290 aSerializer.writeColor(rItem.GetValue());
291 return rStrm;
295 namespace SvxBox
297 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
299 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
300 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
301 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
302 "SvxBoxItem: Is there a new file format?" );
303 return SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
304 SOFFICE_FILEFORMAT_40==nFileFormatVersion ? 0 : BOX_BORDER_STYLE_VERSION;
307 /// Item version for saved border lines. The old version saves the line without style information.
308 const int BORDER_LINE_OLD_VERSION = 0;
309 /// Item version for saved border lies. The new version includes line style.
310 const int BORDER_LINE_WITH_STYLE_VERSION = 1;
312 /// Creates a border line from a stream.
313 static ::editeng::SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
315 sal_uInt16 nOutline, nInline, nDistance;
316 sal_uInt16 nStyle = css::table::BorderLineStyle::NONE;
317 Color aColor;
318 tools::GenericTypeSerializer aSerializer(stream);
319 aSerializer.readColor(aColor);
320 stream.ReadUInt16( nOutline ).ReadUInt16( nInline ).ReadUInt16( nDistance );
322 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
323 stream.ReadUInt16( nStyle );
325 ::editeng::SvxBorderLine border(&aColor);
326 border.GuessLinesWidths(static_cast<SvxBorderLineStyle>(nStyle), nOutline, nInline, nDistance);
327 return border;
330 /// Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
331 static sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
333 return (boxVersion >= BOX_BORDER_STYLE_VERSION)? BORDER_LINE_WITH_STYLE_VERSION : BORDER_LINE_OLD_VERSION;
336 void Create(SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
338 sal_uInt16 nDistance(0);
339 rStrm.ReadUInt16( nDistance );
340 SvxBoxItemLine aLineMap[4] = { SvxBoxItemLine::TOP, SvxBoxItemLine::LEFT,
341 SvxBoxItemLine::RIGHT, SvxBoxItemLine::BOTTOM };
342 sal_Int8 cLine(0);
344 while (rStrm.good())
346 rStrm.ReadSChar( cLine );
348 if( cLine > 3 )
349 break;
351 ::editeng::SvxBorderLine aBorder = CreateBorderLine(rStrm, BorderLineVersionFromBoxVersion(nItemVersion));
352 rItem.SetLine( &aBorder, aLineMap[cLine] );
355 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
357 for(const SvxBoxItemLine & i : aLineMap)
359 sal_uInt16 nDist;
360 rStrm.ReadUInt16( nDist );
361 rItem.SetDistance( nDist, i );
364 else
366 rItem.SetAllDistances(nDistance);
370 /// Store a border line to a stream.
371 static SvStream& StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version)
373 tools::GenericTypeSerializer aSerializer(stream);
374 aSerializer.writeColor(l.GetColor());
376 stream.WriteUInt16( l.GetOutWidth() )
377 .WriteUInt16( l.GetInWidth() )
378 .WriteUInt16( l.GetDistance() );
380 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
381 stream.WriteUInt16( static_cast<sal_uInt16>(l.GetBorderLineStyle()) );
383 return stream;
386 SvStream& Store(const SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
388 rStrm.WriteUInt16( rItem.GetSmallestDistance() );
389 const ::editeng::SvxBorderLine* pLine[ 4 ]; // top, left, right, bottom
390 pLine[ 0 ] = rItem.GetTop();
391 pLine[ 1 ] = rItem.GetLeft();
392 pLine[ 2 ] = rItem.GetRight();
393 pLine[ 3 ] = rItem.GetBottom();
395 for( int i = 0; i < 4; i++ )
397 const ::editeng::SvxBorderLine* l = pLine[ i ];
398 if( l )
400 rStrm.WriteSChar(i);
401 StoreBorderLine(rStrm, *l, BorderLineVersionFromBoxVersion(nItemVersion));
404 sal_Int8 cLine = 4;
405 const sal_uInt16 nTopDist(rItem.GetDistance(SvxBoxItemLine::TOP));
406 const sal_uInt16 nLeftDist(rItem.GetDistance(SvxBoxItemLine::LEFT));
407 const sal_uInt16 nRightDist(rItem.GetDistance(SvxBoxItemLine::RIGHT));
408 const sal_uInt16 nBottomDist(rItem.GetDistance(SvxBoxItemLine::BOTTOM));
410 if( nItemVersion >= BOX_4DISTS_VERSION &&
411 !(nTopDist == nLeftDist &&
412 nTopDist == nRightDist &&
413 nTopDist == nBottomDist) )
415 cLine |= 0x10;
418 rStrm.WriteSChar( cLine );
420 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
422 rStrm.WriteUInt16( nTopDist )
423 .WriteUInt16( nLeftDist )
424 .WriteUInt16( nRightDist )
425 .WriteUInt16( nBottomDist );
428 return rStrm;
432 namespace SvxLine
434 sal_uInt16 GetVersion(sal_uInt16)
436 return 0;
439 void Create(SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
441 short nOutline, nInline, nDistance;
442 Color aColor;
444 tools::GenericTypeSerializer aSerializer(rStrm);
445 aSerializer.readColor(aColor);
446 rStrm.ReadInt16( nOutline ).ReadInt16( nInline ).ReadInt16( nDistance );
447 if( nOutline )
449 ::editeng::SvxBorderLine aLine( &aColor );
450 aLine.GuessLinesWidths(SvxBorderLineStyle::NONE, nOutline, nInline, nDistance);
451 rItem.SetLine( &aLine );
455 SvStream& Store(const SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
457 const ::editeng::SvxBorderLine* pLine(rItem.GetLine());
459 if(nullptr != pLine)
461 tools::GenericTypeSerializer aSerializer(rStrm);
462 aSerializer.writeColor(pLine->GetColor());
463 rStrm.WriteInt16( pLine->GetOutWidth() )
464 .WriteInt16( pLine->GetInWidth() )
465 .WriteInt16( pLine->GetDistance() );
467 else
469 tools::GenericTypeSerializer aSerializer(rStrm);
470 aSerializer.writeColor(Color());
471 rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 );
474 return rStrm;
478 namespace SvxBrush
480 sal_uInt16 GetVersion(sal_uInt16)
482 return BRUSH_GRAPHIC_VERSION;
485 const sal_uInt16 LOAD_GRAPHIC = (sal_uInt16(0x0001));
486 const sal_uInt16 LOAD_LINK = (sal_uInt16(0x0002));
487 const sal_uInt16 LOAD_FILTER = (sal_uInt16(0x0004));
489 void Create(SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
491 bool bTrans;
492 Color aTempColor;
493 Color aTempFillColor;
494 sal_Int8 nStyle;
496 rStrm.ReadCharAsBool( bTrans );
497 TypeSerializer aSerializer(rStrm);
498 aSerializer.readColor(aTempColor);
499 aSerializer.readColor(aTempFillColor);
500 rStrm.ReadSChar( nStyle );
502 switch ( nStyle )
504 case 8: // BRUSH_25:
506 sal_uInt32 nRed = aTempColor.GetRed();
507 sal_uInt32 nGreen = aTempColor.GetGreen();
508 sal_uInt32 nBlue = aTempColor.GetBlue();
509 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed())*2;
510 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen())*2;
511 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue())*2;
512 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/3), static_cast<sal_Int8>(nGreen/3), static_cast<sal_Int8>(nBlue/3) ));
514 break;
516 case 9: // BRUSH_50:
518 sal_uInt32 nRed = aTempColor.GetRed();
519 sal_uInt32 nGreen = aTempColor.GetGreen();
520 sal_uInt32 nBlue = aTempColor.GetBlue();
521 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed());
522 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen());
523 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue());
524 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/2), static_cast<sal_Int8>(nGreen/2), static_cast<sal_Int8>(nBlue/2) ));
526 break;
528 case 10: // BRUSH_75:
530 sal_uInt32 nRed = aTempColor.GetRed()*2;
531 sal_uInt32 nGreen = aTempColor.GetGreen()*2;
532 sal_uInt32 nBlue = aTempColor.GetBlue()*2;
533 nRed += static_cast<sal_uInt32>(aTempFillColor.GetRed());
534 nGreen += static_cast<sal_uInt32>(aTempFillColor.GetGreen());
535 nBlue += static_cast<sal_uInt32>(aTempFillColor.GetBlue());
536 rItem.SetColor(Color( static_cast<sal_Int8>(nRed/3), static_cast<sal_Int8>(nGreen/3), static_cast<sal_Int8>(nBlue/3) ));
538 break;
540 case 0: // BRUSH_NULL:
541 rItem.SetColor(COL_TRANSPARENT);
542 break;
544 default:
545 rItem.SetColor(aTempColor);
548 if ( nItemVersion < BRUSH_GRAPHIC_VERSION )
549 return;
551 sal_uInt16 nDoLoad = 0;
552 sal_Int8 nPos;
554 rStrm.ReadUInt16( nDoLoad );
556 if ( nDoLoad & LOAD_GRAPHIC )
558 Graphic aGraphic;
559 aSerializer.readGraphic(aGraphic);
560 rItem.SetGraphicObject(GraphicObject(std::move(aGraphic)));
562 if( SVSTREAM_FILEFORMAT_ERROR == rStrm.GetError() )
564 rStrm.ResetError();
565 rStrm.SetError( ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT.MakeWarning() );
569 if ( nDoLoad & LOAD_LINK )
571 // UNICODE: rStrm >> aRel;
572 OUString aRel = rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet());
574 // TODO/MBA: how can we get a BaseURL here?!
575 OSL_FAIL("No BaseURL!");
576 OUString aAbs = INetURLObject::GetAbsURL( u"", aRel );
577 DBG_ASSERT( !aAbs.isEmpty(), "Invalid URL!" );
578 rItem.SetGraphicLink(aAbs);
581 if ( nDoLoad & LOAD_FILTER )
583 // UNICODE: rStrm >> maStrFilter;
584 rItem.SetGraphicFilter(rStrm.ReadUniOrByteString(rStrm.GetStreamCharSet()));
587 rStrm.ReadSChar( nPos );
589 rItem.SetGraphicPos(static_cast<SvxGraphicPosition>(nPos));
592 SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16)
594 rStrm.WriteBool( false );
595 TypeSerializer aSerializer(rStrm);
596 aSerializer.writeColor(rItem.GetColor());
597 aSerializer.writeColor(rItem.GetColor());
598 rStrm.WriteSChar( rItem.GetColor().IsTransparent() ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
600 sal_uInt16 nDoLoad = 0;
601 const GraphicObject* pGraphicObject(rItem.GetGraphicObject());
603 if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
604 nDoLoad |= LOAD_GRAPHIC;
605 if ( !rItem.GetGraphicLink().isEmpty() )
606 nDoLoad |= LOAD_LINK;
607 if ( !rItem.GetGraphicFilter().isEmpty() )
608 nDoLoad |= LOAD_FILTER;
609 rStrm.WriteUInt16( nDoLoad );
611 if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
613 aSerializer.writeGraphic(pGraphicObject->GetGraphic());
615 if ( !rItem.GetGraphicLink().isEmpty() )
617 OSL_FAIL("No BaseURL!");
618 // TODO/MBA: how to get a BaseURL?!
619 OUString aRel = INetURLObject::GetRelURL( u"", rItem.GetGraphicLink() );
620 // UNICODE: rStrm << aRel;
621 rStrm.WriteUniOrByteString(aRel, rStrm.GetStreamCharSet());
623 if ( !rItem.GetGraphicFilter().isEmpty() )
625 // UNICODE: rStrm << rItem.GetGraphicFilter();
626 rStrm.WriteUniOrByteString(rItem.GetGraphicFilter(), rStrm.GetStreamCharSet());
628 rStrm.WriteSChar( rItem.GetGraphicPos() );
629 return rStrm;
633 namespace SvxAdjust
635 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
637 return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
638 ? 0 : ADJUST_LASTBLOCK_VERSION;
641 void Create(SvxAdjustItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
643 char eAdjustment;
644 rStrm.ReadChar(eAdjustment);
645 rItem.SetAdjust(static_cast<::SvxAdjust>(eAdjustment));
647 if( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
649 sal_Int8 nFlags;
650 rStrm.ReadSChar( nFlags );
651 rItem.SetAsFlags(nFlags);
655 SvStream& Store(const SvxAdjustItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
657 rStrm.WriteChar( static_cast<char>(rItem.GetAdjust()) );
658 if ( nItemVersion >= ADJUST_LASTBLOCK_VERSION )
660 const sal_Int8 nFlags(rItem.GetAsFlags());
661 rStrm.WriteSChar( nFlags );
663 return rStrm;
667 namespace SvxHorJustify
669 sal_uInt16 GetVersion(sal_uInt16)
671 return 0;
674 void Create(SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
676 sal_uInt16 nVal(0);
677 rStrm.ReadUInt16( nVal );
678 rItem.SetValue(static_cast<::SvxCellHorJustify>(nVal));
681 SvStream& Store(const SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
683 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
684 return rStrm;
688 namespace SvxVerJustify
690 sal_uInt16 GetVersion(sal_uInt16)
692 return 0;
695 void Create(SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
697 sal_uInt16 nVal(0);
698 rStrm.ReadUInt16( nVal );
699 rItem.SetValue(static_cast<::SvxCellVerJustify>(nVal));
702 SvStream& Store(const SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
704 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
705 return rStrm;
709 namespace SvxFrameDirection
711 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
713 return SOFFICE_FILEFORMAT_50 > nFileFormatVersion ? USHRT_MAX : 0;
716 void Create(SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
718 sal_uInt16 nVal(0);
719 rStrm.ReadUInt16( nVal );
720 rItem.SetValue(static_cast<::SvxFrameDirection>(nVal));
723 SvStream& Store(const SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
725 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
726 return rStrm;
730 namespace SvxFormatBreak
732 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
734 DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
735 SOFFICE_FILEFORMAT_40==nFileFormatVersion ||
736 SOFFICE_FILEFORMAT_50==nFileFormatVersion,
737 "SvxFormatBreakItem: Is there a new file format? ");
738 return SOFFICE_FILEFORMAT_31==nFileFormatVersion ||
739 SOFFICE_FILEFORMAT_40==nFileFormatVersion ? 0 : FMTBREAK_NOAUTO;
742 void Create(SvxFormatBreakItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
744 sal_Int8 eBreak, bDummy;
745 rStrm.ReadSChar( eBreak );
746 if( FMTBREAK_NOAUTO > nItemVersion )
747 rStrm.ReadSChar( bDummy );
748 rItem.SetValue(static_cast<::SvxBreak>(eBreak));
751 SvStream& Store(const SvxFormatBreakItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
753 rStrm.WriteSChar( rItem.GetEnumValue() );
754 if( FMTBREAK_NOAUTO > nItemVersion )
755 rStrm.WriteSChar( 0x01 );
756 return rStrm;
760 namespace SvxFormatKeep
762 sal_uInt16 GetVersion(sal_uInt16)
764 return 0;
767 void Create(SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
769 // derived from SfxBoolItem, but that uses
770 // rStream.ReadCharAsBool( tmp );
771 sal_Int8 bIsKeep;
772 rStrm.ReadSChar( bIsKeep );
773 rItem.SetValue(static_cast<bool>(bIsKeep));
776 SvStream& Store(const SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
778 // derived from SfxBoolItem, but that uses
779 // rStream.WriteBool( m_bValue ); // not bool for serialization!
780 rStrm.WriteSChar( static_cast<sal_Int8>(rItem.GetValue()) );
781 return rStrm;
785 namespace SvxShadow
787 sal_uInt16 GetVersion(sal_uInt16)
789 return 0;
792 void Create(SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
794 sal_Int8 cLoc;
795 sal_uInt16 _nWidth;
796 bool bTrans;
797 Color aColor;
798 Color aFillColor;
799 sal_Int8 nStyle;
800 rStrm.ReadSChar( cLoc ).ReadUInt16( _nWidth ).ReadCharAsBool( bTrans );
801 tools::GenericTypeSerializer aSerializer(rStrm);
802 aSerializer.readColor(aColor);
803 aSerializer.readColor(aFillColor);
804 rStrm.ReadSChar(nStyle);
805 aColor.SetAlpha(bTrans ? 0 : 255);
807 rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc));
808 rItem.SetWidth(_nWidth);
809 rItem.SetColor(aColor);
812 SvStream& Store(const SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
814 rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) )
815 .WriteUInt16( rItem.GetWidth() )
816 .WriteBool( rItem.GetColor().IsTransparent() );
817 tools::GenericTypeSerializer aSerializer(rStrm);
818 aSerializer.writeColor(rItem.GetColor());
819 aSerializer.writeColor(rItem.GetColor());
820 rStrm.WriteSChar( rItem.GetColor().IsTransparent() ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID
821 return rStrm;
826 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */