LibreOffice Module editeng (master) 1
legacyitem.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <unotools/fontdefs.hxx>
22#include <tools/tenccvt.hxx>
23#include <tools/stream.hxx>
25#include <vcl/graph.hxx>
26#include <vcl/GraphicObject.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>
36#include <editeng/colritem.hxx>
37#include <editeng/boxitem.hxx>
39#include <editeng/lineitem.hxx>
40#include <editeng/brushitem.hxx>
41#include <editeng/editerr.hxx>
46#include <editeng/keepitem.hxx>
47#include <editeng/shaditem.hxx>
49
50
51void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP)
52{
53 rItem.legacy_direct_set(nH, nP, eP);
54}
55
56namespace legacy
57{
58 namespace SvxFont
59 {
60 sal_uInt16 GetVersion(sal_uInt16)
61 {
62 return 0;
63 }
64
65 void Create(SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
66 {
67 sal_uInt8 _eFamily, eFontPitch, eFontTextEncoding;
68 OUString aName, aStyle;
69 rStrm.ReadUChar( _eFamily );
70 rStrm.ReadUChar( eFontPitch );
71 rStrm.ReadUChar( eFontTextEncoding );
72
73 // UNICODE: rStrm >> aName;
75
76 // UNICODE: rStrm >> aStyle;
78
79 // Set the "correct" textencoding
80 eFontTextEncoding = static_cast<sal_uInt8>(GetSOLoadTextEncoding( eFontTextEncoding ));
81
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;
85
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;
91 if ( nMagic == 0xFE331188 )
92 {
93 aName = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
94 aStyle = rStrm.ReadUniOrByteString( RTL_TEXTENCODING_UNICODE );
95 }
96 else
97 {
98 rStrm.Seek( nStreamPos );
99 }
100
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));
106 }
107
108 SvStream& Store(const SvxFontItem& rItem, SvStream& rStrm, sal_uInt16)
109 {
110 const bool bToBats(IsOpenSymbol(rItem.GetFamilyName()));
111
112 rStrm.WriteUChar(rItem.GetFamily()).WriteUChar(rItem.GetPitch()).WriteUChar(bToBats ?
113 RTL_TEXTENCODING_SYMBOL :
115
116 const OUString aStoreFamilyName(bToBats ? "StarBats" : rItem.GetFamilyName());
117
120
121 return rStrm;
122 }
123 }
124
125 namespace SvxFontHeight
126 {
127 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
128 {
129 return (nFileFormatVersion <= SOFFICE_FILEFORMAT_40)
132 }
133
135 {
136 sal_uInt16 nsize, nprop = 0;
137 MapUnit nPropUnit = MapUnit::MapRelative;
138
139 rStrm.ReadUInt16( nsize );
140
142 rStrm.ReadUInt16( nprop );
143 else
144 {
145 sal_uInt8 nP;
146 rStrm .ReadUChar( nP );
147 nprop = static_cast<sal_uInt16>(nP);
148 }
149
151 {
152 sal_uInt16 nTmp;
153 rStrm.ReadUInt16( nTmp );
154 nPropUnit = static_cast<MapUnit>(nTmp);
155 }
156
157 Create_legacy_direct_set(rItem, nsize, nprop, nPropUnit);
158 }
159
161 {
162 rStrm.WriteUInt16( rItem.GetHeight() );
163
165 rStrm.WriteUInt16( rItem.GetProp() ).WriteUInt16( static_cast<sal_uInt16>(rItem.GetPropUnit()) );
166 else
167 {
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 );
174 }
175 return rStrm;
176 }
177 }
178
179 namespace SvxWeight
180 {
181 sal_uInt16 GetVersion(sal_uInt16)
182 {
183 return 0;
184 }
185
186 void Create(SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
187 {
188 sal_uInt8 nWeight(0);
189 rStrm.ReadUChar(nWeight);
190 rItem.SetValue(static_cast<FontWeight>(nWeight));
191 }
192
193 SvStream& Store(const SvxWeightItem& rItem, SvStream& rStrm, sal_uInt16)
194 {
195 rStrm.WriteUChar(rItem.GetValue());
196 return rStrm;
197 }
198 }
199
200 namespace SvxPosture
201 {
202 sal_uInt16 GetVersion(sal_uInt16)
203 {
204 return 0;
205 }
206
207 void Create(SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
208 {
209 sal_uInt8 nPosture(0);
210 rStrm.ReadUChar(nPosture);
211 rItem.SetValue(static_cast<FontItalic>(nPosture));
212 }
213
214 SvStream& Store(const SvxPostureItem& rItem, SvStream& rStrm, sal_uInt16)
215 {
216 rStrm.WriteUChar( rItem.GetValue() );
217 return rStrm;
218 }
219 }
220
221 namespace SvxTextLine // SvxUnderlineItem, SvxOverlineItem -> SvxTextLineItem
222 {
223 sal_uInt16 GetVersion(sal_uInt16)
224 {
225 return 0;
226 }
227
228 void Create(SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
229 {
230 sal_uInt8 nState(0);
232 rItem.SetValue(static_cast<FontLineStyle>(nState));
233 // GetColor() is *not* saved/loaded ?!?
234 }
235
236 SvStream& Store(const SvxTextLineItem& rItem, SvStream& rStrm, sal_uInt16)
237 {
238 rStrm.WriteUChar(rItem.GetValue());
239 // GetColor() is *not* saved/loaded ?!?
240 return rStrm;
241 }
242 }
243
244 namespace SvxCrossedOut
245 {
246 sal_uInt16 GetVersion(sal_uInt16)
247 {
248 return 0;
249 }
250
251 void Create(SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
252 {
253 sal_uInt8 eCross(0);
254 rStrm.ReadUChar(eCross);
255 rItem.SetValue(static_cast<FontStrikeout>(eCross));
256 }
257
258 SvStream& Store(const SvxCrossedOutItem& rItem, SvStream& rStrm, sal_uInt16)
259 {
260 rStrm.WriteUChar(rItem.GetValue());
261 return rStrm;
262 }
263 }
264
265 namespace SvxColor
266 {
267 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
268 {
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;
274 }
275
276 void Create(SvxColorItem& rItem, SvStream& rStrm, sal_uInt16)
277 {
278 Color aColor(COL_AUTO);
280 aSerializer.readColor(aColor);
281 rItem.SetValue(aColor);
282 }
283
285 {
288 aSerializer.writeColor(COL_BLACK);
289 else
290 aSerializer.writeColor(rItem.GetValue());
291 return rStrm;
292 }
293 }
294
295 namespace SvxBox
296 {
297 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
298 {
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;
305 }
306
311
313 static ::editeng::SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
314 {
315 sal_uInt16 nOutline, nInline, nDistance;
316 sal_uInt16 nStyle = css::table::BorderLineStyle::NONE;
317 Color aColor;
319 aSerializer.readColor(aColor);
320 stream.ReadUInt16( nOutline ).ReadUInt16( nInline ).ReadUInt16( nDistance );
321
322 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
323 stream.ReadUInt16( nStyle );
324
325 ::editeng::SvxBorderLine border(&aColor);
326 border.GuessLinesWidths(static_cast<SvxBorderLineStyle>(nStyle), nOutline, nInline, nDistance);
327 return border;
328 }
329
331 static sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
332 {
334 }
335
336 void Create(SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
337 {
338 sal_uInt16 nDistance(0);
339 rStrm.ReadUInt16( nDistance );
342 sal_Int8 cLine(0);
343
344 while (rStrm.good())
345 {
346 rStrm.ReadSChar( cLine );
347
348 if( cLine > 3 )
349 break;
350
352 rItem.SetLine( &aBorder, aLineMap[cLine] );
353 }
354
355 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine&0x10) != 0 )
356 {
357 for(const SvxBoxItemLine & i : aLineMap)
358 {
359 sal_uInt16 nDist;
360 rStrm.ReadUInt16( nDist );
361 rItem.SetDistance( nDist, i );
362 }
363 }
364 else
365 {
366 rItem.SetAllDistances(nDistance);
367 }
368 }
369
371 static SvStream& StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version)
372 {
374 aSerializer.writeColor(l.GetColor());
375
376 stream.WriteUInt16( l.GetOutWidth() )
377 .WriteUInt16( l.GetInWidth() )
378 .WriteUInt16( l.GetDistance() );
379
380 if (version >= BORDER_LINE_WITH_STYLE_VERSION)
381 stream.WriteUInt16( static_cast<sal_uInt16>(l.GetBorderLineStyle()) );
382
383 return stream;
384 }
385
386 SvStream& Store(const SvxBoxItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
387 {
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();
394
395 for( int i = 0; i < 4; i++ )
396 {
397 const ::editeng::SvxBorderLine* l = pLine[ i ];
398 if( l )
399 {
402 }
403 }
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));
409
411 !(nTopDist == nLeftDist &&
412 nTopDist == nRightDist &&
413 nTopDist == nBottomDist) )
414 {
415 cLine |= 0x10;
416 }
417
418 rStrm.WriteSChar( cLine );
419
420 if( nItemVersion >= BOX_4DISTS_VERSION && (cLine & 0x10) != 0 )
421 {
422 rStrm.WriteUInt16( nTopDist )
423 .WriteUInt16( nLeftDist )
424 .WriteUInt16( nRightDist )
425 .WriteUInt16( nBottomDist );
426 }
427
428 return rStrm;
429 }
430 }
431
432 namespace SvxLine
433 {
434 sal_uInt16 GetVersion(sal_uInt16)
435 {
436 return 0;
437 }
438
439 void Create(SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
440 {
441 short nOutline, nInline, nDistance;
442 Color aColor;
443
445 aSerializer.readColor(aColor);
446 rStrm.ReadInt16( nOutline ).ReadInt16( nInline ).ReadInt16( nDistance );
447 if( nOutline )
448 {
449 ::editeng::SvxBorderLine aLine( &aColor );
450 aLine.GuessLinesWidths(SvxBorderLineStyle::NONE, nOutline, nInline, nDistance);
451 rItem.SetLine( &aLine );
452 }
453 }
454
455 SvStream& Store(const SvxLineItem& rItem, SvStream& rStrm, sal_uInt16)
456 {
457 const ::editeng::SvxBorderLine* pLine(rItem.GetLine());
458
459 if(nullptr != pLine)
460 {
462 aSerializer.writeColor(pLine->GetColor());
463 rStrm.WriteInt16( pLine->GetOutWidth() )
464 .WriteInt16( pLine->GetInWidth() )
465 .WriteInt16( pLine->GetDistance() );
466 }
467 else
468 {
470 aSerializer.writeColor(Color());
471 rStrm.WriteInt16( 0 ).WriteInt16( 0 ).WriteInt16( 0 );
472 }
473
474 return rStrm;
475 }
476 }
477
478 namespace SvxBrush
479 {
480 sal_uInt16 GetVersion(sal_uInt16)
481 {
483 }
484
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));
488
489 void Create(SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
490 {
491 bool bTrans;
492 Color aTempColor;
493 Color aTempFillColor;
494 sal_Int8 nStyle;
495
496 rStrm.ReadCharAsBool( bTrans );
497 TypeSerializer aSerializer(rStrm);
498 aSerializer.readColor(aTempColor);
499 aSerializer.readColor(aTempFillColor);
500 rStrm.ReadSChar( nStyle );
501
502 switch ( nStyle )
503 {
504 case 8: // BRUSH_25:
505 {
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) ));
513 }
514 break;
515
516 case 9: // BRUSH_50:
517 {
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) ));
525 }
526 break;
527
528 case 10: // BRUSH_75:
529 {
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) ));
537 }
538 break;
539
540 case 0: // BRUSH_NULL:
542 break;
543
544 default:
545 rItem.SetColor(aTempColor);
546 }
547
549 return;
550
551 sal_uInt16 nDoLoad = 0;
553
554 rStrm.ReadUInt16( nDoLoad );
555
556 if ( nDoLoad & LOAD_GRAPHIC )
557 {
558 Graphic aGraphic;
559 aSerializer.readGraphic(aGraphic);
560 rItem.SetGraphicObject(GraphicObject(std::move(aGraphic)));
561
563 {
566 }
567 }
568
569 if ( nDoLoad & LOAD_LINK )
570 {
571 // UNICODE: rStrm >> aRel;
573
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);
579 }
580
581 if ( nDoLoad & LOAD_FILTER )
582 {
583 // UNICODE: rStrm >> maStrFilter;
585 }
586
588
589 rItem.SetGraphicPos(static_cast<SvxGraphicPosition>(nPos));
590 }
591
592 SvStream& Store(const SvxBrushItem& rItem, SvStream& rStrm, sal_uInt16)
593 {
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
599
600 sal_uInt16 nDoLoad = 0;
601 const GraphicObject* pGraphicObject(rItem.GetGraphicObject());
602
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 );
610
611 if (nullptr != pGraphicObject && rItem.GetGraphicLink().isEmpty())
612 {
613 aSerializer.writeGraphic(pGraphicObject->GetGraphic());
614 }
615 if ( !rItem.GetGraphicLink().isEmpty() )
616 {
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;
622 }
623 if ( !rItem.GetGraphicFilter().isEmpty() )
624 {
625 // UNICODE: rStrm << rItem.GetGraphicFilter();
627 }
628 rStrm.WriteSChar( rItem.GetGraphicPos() );
629 return rStrm;
630 }
631 }
632
633 namespace SvxAdjust
634 {
635 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
636 {
637 return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
639 }
640
641 void Create(SvxAdjustItem& rItem, SvStream& rStrm, sal_uInt16 nItemVersion)
642 {
643 char eAdjustment;
644 rStrm.ReadChar(eAdjustment);
645 rItem.SetAdjust(static_cast<::SvxAdjust>(eAdjustment));
646
648 {
649 sal_Int8 nFlags;
650 rStrm.ReadSChar( nFlags );
651 rItem.SetAsFlags(nFlags);
652 }
653 }
654
656 {
657 rStrm.WriteChar( static_cast<char>(rItem.GetAdjust()) );
659 {
660 const sal_Int8 nFlags(rItem.GetAsFlags());
661 rStrm.WriteSChar( nFlags );
662 }
663 return rStrm;
664 }
665 }
666
667 namespace SvxHorJustify
668 {
669 sal_uInt16 GetVersion(sal_uInt16)
670 {
671 return 0;
672 }
673
674 void Create(SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
675 {
676 sal_uInt16 nVal(0);
677 rStrm.ReadUInt16( nVal );
678 rItem.SetValue(static_cast<::SvxCellHorJustify>(nVal));
679 }
680
681 SvStream& Store(const SvxHorJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
682 {
683 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
684 return rStrm;
685 }
686 }
687
688 namespace SvxVerJustify
689 {
690 sal_uInt16 GetVersion(sal_uInt16)
691 {
692 return 0;
693 }
694
695 void Create(SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
696 {
697 sal_uInt16 nVal(0);
698 rStrm.ReadUInt16( nVal );
699 rItem.SetValue(static_cast<::SvxCellVerJustify>(nVal));
700 }
701
702 SvStream& Store(const SvxVerJustifyItem& rItem, SvStream& rStrm, sal_uInt16)
703 {
704 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
705 return rStrm;
706 }
707 }
708
710 {
711 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
712 {
713 return SOFFICE_FILEFORMAT_50 > nFileFormatVersion ? USHRT_MAX : 0;
714 }
715
716 void Create(SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
717 {
718 sal_uInt16 nVal(0);
719 rStrm.ReadUInt16( nVal );
720 rItem.SetValue(static_cast<::SvxFrameDirection>(nVal));
721 }
722
723 SvStream& Store(const SvxFrameDirectionItem& rItem, SvStream& rStrm, sal_uInt16)
724 {
725 rStrm.WriteUInt16( static_cast<sal_uInt16>(rItem.GetValue()) );
726 return rStrm;
727 }
728 }
729
730 namespace SvxFormatBreak
731 {
732 sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
733 {
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;
740 }
741
743 {
744 sal_Int8 eBreak, bDummy;
745 rStrm.ReadSChar( eBreak );
747 rStrm.ReadSChar( bDummy );
748 rItem.SetValue(static_cast<::SvxBreak>(eBreak));
749 }
750
752 {
753 rStrm.WriteSChar( rItem.GetEnumValue() );
755 rStrm.WriteSChar( 0x01 );
756 return rStrm;
757 }
758 }
759
760 namespace SvxFormatKeep
761 {
762 sal_uInt16 GetVersion(sal_uInt16)
763 {
764 return 0;
765 }
766
767 void Create(SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
768 {
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));
774 }
775
776 SvStream& Store(const SvxFormatKeepItem& rItem, SvStream& rStrm, sal_uInt16)
777 {
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;
782 }
783 }
784
785 namespace SvxShadow
786 {
787 sal_uInt16 GetVersion(sal_uInt16)
788 {
789 return 0;
790 }
791
792 void Create(SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
793 {
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 );
802 aSerializer.readColor(aColor);
803 aSerializer.readColor(aFillColor);
804 rStrm.ReadSChar(nStyle);
805 aColor.SetAlpha(bTrans ? 0 : 255);
806
807 rItem.SetLocation(static_cast<SvxShadowLocation>(cLoc));
808 rItem.SetWidth(_nWidth);
809 rItem.SetColor(aColor);
810 }
811
812 SvStream& Store(const SvxShadowItem& rItem, SvStream& rStrm, sal_uInt16)
813 {
814 rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) )
815 .WriteUInt16( rItem.GetWidth() )
816 .WriteBool( rItem.GetColor().IsTransparent() );
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;
822 }
823 }
824}
825
826/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION
Definition: adjustitem.hxx:33
SvxBorderLineStyle
Definition: borderline.hxx:50
@ NONE
No border line.
constexpr sal_uInt16 BOX_BORDER_STYLE_VERSION
This version causes SvxBoxItem to store the styles for its border lines when serializing to stream.
Definition: boxitem.hxx:55
SvxBoxItemLine
Definition: boxitem.hxx:42
constexpr sal_uInt16 BOX_4DISTS_VERSION
This version causes SvxBoxItem to store the 4 cell spacing distances separately when serializing to s...
Definition: boxitem.hxx:50
SvxGraphicPosition
Definition: brushitem.hxx:33
constexpr sal_uInt16 BRUSH_GRAPHIC_VERSION
Definition: brushitem.hxx:30
sal_uInt8 GetBlue() const
sal_uInt8 GetRed() const
bool IsTransparent() const
sal_uInt8 GetGreen() const
void SetAlpha(sal_uInt8 nAlpha)
const Graphic & GetGraphic() const
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
static OUString GetRelURL(std::u16string_view rTheBaseURIRef, OUString const &rTheAbsURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
void SetValue(bool const bTheValue)
bool GetValue() const
virtual sal_uInt16 GetEnumValue() const override
EnumT GetValue() const
void SetValue(EnumT nTheValue)
virtual void ResetError()
SvStream & ReadCharAsBool(bool &rBool)
sal_uInt64 Tell() const
bool good() const
SvStream & WriteUniOrByteString(std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet)
SvStream & ReadInt16(sal_Int16 &rInt16)
SvStream & WriteBool(bool b)
SvStream & WriteInt16(sal_Int16 nInt16)
SvStream & WriteUChar(unsigned char nChar)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
void SetError(ErrCode nErrorCode)
SvStream & ReadChar(char &rChar)
sal_uInt64 Seek(sal_uInt64 nPos)
SvStream & WriteChar(char nChar)
rtl_TextEncoding GetStreamCharSet() const
ErrCode GetError() const
SvStream & ReadSChar(signed char &rChar)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
SvStream & WriteSChar(signed char nChar)
SvStream & ReadUChar(unsigned char &rChar)
SvxAdjust GetAdjust() const
Definition: adjustitem.hxx:108
void SetAdjust(const SvxAdjust eType)
Definition: adjustitem.hxx:80
void SetAsFlags(sal_Int8 nFlags)
Definition: adjustitem.hxx:133
sal_Int8 GetAsFlags() const
Definition: adjustitem.hxx:121
const editeng::SvxBorderLine * GetTop() const
Definition: boxitem.hxx:98
sal_uInt16 GetSmallestDistance() const
Definition: frmitems.cxx:3085
const editeng::SvxBorderLine * GetRight() const
Definition: boxitem.hxx:110
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
Definition: frmitems.cxx:3061
const editeng::SvxBorderLine * GetLeft() const
Definition: boxitem.hxx:106
sal_Int16 GetDistance(SvxBoxItemLine nLine, bool bAllowNegative=false) const
Definition: frmitems.cxx:3100
void SetDistance(sal_Int16 nNew, SvxBoxItemLine nLine)
Definition: frmitems.cxx:3129
const editeng::SvxBorderLine * GetBottom() const
Definition: boxitem.hxx:102
void SetAllDistances(sal_Int16 nNew)
Definition: boxitem.hxx:143
void SetGraphicPos(SvxGraphicPosition eNew)
Definition: frmitems.cxx:4471
const GraphicObject * GetGraphicObject(OUString const &referer=OUString()) const
Definition: frmitems.cxx:4392
const Color & GetColor() const
Definition: brushitem.hxx:90
void SetGraphicLink(const OUString &rNew)
Definition: frmitems.cxx:4530
const OUString & GetGraphicFilter() const
Definition: brushitem.hxx:113
void SetColor(const Color &rCol)
Definition: brushitem.hxx:92
const OUString & GetGraphicLink() const
Definition: brushitem.hxx:112
void SetGraphicObject(const GraphicObject &rNewObj)
Definition: frmitems.cxx:4510
SvxGraphicPosition GetGraphicPos() const
Definition: brushitem.hxx:107
void SetGraphicFilter(const OUString &rNew)
Definition: frmitems.cxx:4541
SvxColorItem item describes a color.
Definition: colritem.hxx:32
const Color & GetValue() const
Definition: colritem.hxx:57
void SetValue(const Color &rNewColor)
Definition: colritem.hxx:61
void SetValue(EnumT nTheValue)
sal_uInt32 GetHeight() const
Definition: fhgtitem.hxx:74
MapUnit GetPropUnit() const
Definition: fhgtitem.hxx:85
void legacy_direct_set(sal_uInt32 nH, sal_uInt16 nP, MapUnit eP)
Definition: fhgtitem.hxx:46
sal_uInt16 GetProp() const
Definition: fhgtitem.hxx:83
This item describes a Font.
Definition: fontitem.hxx:30
void SetStyleName(const OUString &rStyleName)
Definition: fontitem.hxx:68
FontFamily GetFamily() const
Definition: fontitem.hxx:81
FontPitch GetPitch() const
Definition: fontitem.hxx:90
void SetFamily(FontFamily _eFamily)
Definition: fontitem.hxx:77
void SetPitch(FontPitch _ePitch)
Definition: fontitem.hxx:86
const OUString & GetStyleName() const
Definition: fontitem.hxx:72
void SetFamilyName(const OUString &rFamilyName)
Definition: fontitem.hxx:59
rtl_TextEncoding GetCharSet() const
Definition: fontitem.hxx:99
const OUString & GetFamilyName() const
Definition: fontitem.hxx:63
void SetCharSet(rtl_TextEncoding _eEncoding)
Definition: fontitem.hxx:95
const editeng::SvxBorderLine * GetLine() const
Definition: lineitem.hxx:61
void SetLine(const editeng::SvxBorderLine *pNew)
Definition: frmitems.cxx:3976
sal_uInt16 GetWidth() const
Definition: shaditem.hxx:67
const Color & GetColor() const
Definition: shaditem.hxx:64
void SetLocation(SvxShadowLocation eNew)
Definition: shaditem.hxx:71
SvxShadowLocation GetLocation() const
Definition: shaditem.hxx:68
void SetWidth(sal_uInt16 nNew)
Definition: shaditem.hxx:70
void SetColor(const Color &rNew)
Definition: shaditem.hxx:65
void SetValue(EnumT nTheValue)
void readGraphic(Graphic &rGraphic)
void writeGraphic(const Graphic &rGraphic)
void GuessLinesWidths(SvxBorderLineStyle nStyle, sal_uInt16 nOut, sal_uInt16 nIn=0, sal_uInt16 nDist=0)
Guess the style and width from the three lines widths values.
Definition: borderline.cxx:435
void writeColor(const Color &rColor)
void readColor(Color &rColor)
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
#define VERSION_USEAUTOCOLOR
Definition: colritem.hxx:27
#define DBG_ASSERT(sCon, aError)
Reference< XOutputStream > stream
float u
#define ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT
Definition: editerr.hxx:25
sal_Int32 nState
#define SVSTREAM_FILEFORMAT_ERROR
constexpr sal_uInt16 FONTHEIGHT_16_VERSION
Definition: fhgtitem.hxx:35
constexpr sal_uInt16 FONTHEIGHT_UNIT_VERSION
Definition: fhgtitem.hxx:36
#define SOFFICE_FILEFORMAT_40
#define SOFFICE_FILEFORMAT_31
#define SOFFICE_FILEFORMAT_50
UNOTOOLS_DLLPUBLIC bool IsOpenSymbol(std::u16string_view rFontName)
FontLineStyle
FontStrikeout
FontPitch
FontItalic
FontFamily
constexpr sal_uInt16 FMTBREAK_NOAUTO
SvxFrameDirection
Defines possible text directions in frames.
Definition: frmdir.hxx:31
OUString aName
void Create_legacy_direct_set(SvxFontHeightItem &rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP)
Definition: legacyitem.cxx:51
sal_uInt16 nPos
MapUnit
int i
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:635
void Create(SvxAdjustItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:641
SvStream & Store(const SvxAdjustItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:655
void SvStream & rStrm
Definition: legacyitem.hxx:144
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:144
SvStream & Store(const SvxBoxItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:386
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:297
const int BORDER_LINE_WITH_STYLE_VERSION
Item version for saved border lies. The new version includes line style.
Definition: legacyitem.cxx:310
void Create(SvxBoxItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:336
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:123
void SvStream & rStrm
Definition: legacyitem.hxx:123
::editeng::SvxBorderLine CreateBorderLine(SvStream &stream, sal_uInt16 version)
Creates a border line from a stream.
Definition: legacyitem.cxx:313
static sal_uInt16 BorderLineVersionFromBoxVersion(sal_uInt16 boxVersion)
Retrieves a BORDER_LINE_* version from a BOX_BORDER_* version.
Definition: legacyitem.cxx:331
static SvStream & StoreBorderLine(SvStream &stream, const ::editeng::SvxBorderLine &l, sal_uInt16 version)
Store a border line to a stream.
Definition: legacyitem.cxx:371
const int BORDER_LINE_OLD_VERSION
Item version for saved border lines. The old version saves the line without style information.
Definition: legacyitem.cxx:308
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:480
SvStream & Store(const SvxBrushItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:592
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:137
const sal_uInt16 LOAD_LINK
Definition: legacyitem.cxx:486
void SvStream & rStrm
Definition: legacyitem.hxx:137
const sal_uInt16 LOAD_FILTER
Definition: legacyitem.cxx:487
const sal_uInt16 LOAD_GRAPHIC
Definition: legacyitem.cxx:485
void Create(SvxBrushItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:489
SvStream & Store(const SvxColorItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:284
void Create(SvxColorItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:276
void SvStream & rStrm
Definition: legacyitem.hxx:116
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:116
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:267
void SvStream & rStrm
Definition: legacyitem.hxx:106
void Create(SvxCrossedOutItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:251
SvStream & Store(const SvxCrossedOutItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:258
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:246
void Create(SvxFontHeightItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:134
void SvStream & rStrm
Definition: legacyitem.hxx:78
SvStream & Store(const SvxFontHeightItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:160
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:78
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:127
void SvStream & rStrm
Definition: legacyitem.hxx:71
void SvStream sal_uInt16 nItemVersion
Definition: legacyitem.hxx:71
SvStream & Store(const SvxFontItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:108
void Create(SvxFontItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:65
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:60
void Create(SvxFormatBreakItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:742
SvStream & Store(const SvxFormatBreakItem &rItem, SvStream &rStrm, sal_uInt16 nItemVersion)
Definition: legacyitem.cxx:751
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:732
SvStream & Store(const SvxFormatKeepItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:776
void Create(SvxFormatKeepItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:767
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:762
sal_uInt16 GetVersion(sal_uInt16 nFileFormatVersion)
Definition: legacyitem.cxx:711
void Create(SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:716
SvStream & Store(const SvxFrameDirectionItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:723
SvStream & Store(const SvxHorJustifyItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:681
void Create(SvxHorJustifyItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:674
void SvStream & rStrm
Definition: legacyitem.hxx:151
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:669
void Create(SvxLineItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:439
void SvStream & rStrm
Definition: legacyitem.hxx:130
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:434
SvStream & Store(const SvxLineItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:455
void Create(SvxPostureItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:207
void SvStream & rStrm
Definition: legacyitem.hxx:92
SvStream & Store(const SvxPostureItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:214
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:202
SvStream & Store(const SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:812
void Create(SvxShadowItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:792
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:787
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:223
void Create(SvxTextLineItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:228
void SvStream & rStrm
Definition: legacyitem.hxx:99
SvStream & Store(const SvxTextLineItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:236
void Create(SvxVerJustifyItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:695
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:690
SvStream & Store(const SvxVerJustifyItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:702
void SvStream & rStrm
Definition: legacyitem.hxx:158
void SvStream & rStrm
Definition: legacyitem.hxx:85
SvStream & Store(const SvxWeightItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:193
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:181
void Create(SvxWeightItem &rItem, SvStream &rStrm, sal_uInt16)
Definition: legacyitem.cxx:186
FontWeight
const sal_uInt16 nMagic
SvxCellHorJustify
Definition: svxenum.hxx:100
SvxShadowLocation
Definition: svxenum.hxx:43
SvxCellVerJustify
Definition: svxenum.hxx:116
SvxBreak
Definition: svxenum.hxx:88
SvxAdjust
Definition: svxenum.hxx:77
TOOLS_DLLPUBLIC rtl_TextEncoding GetSOStoreTextEncoding(rtl_TextEncoding eEncoding)
TOOLS_DLLPUBLIC rtl_TextEncoding GetSOLoadTextEncoding(rtl_TextEncoding eEncoding)
unsigned char sal_uInt8
signed char sal_Int8