LibreOffice Module sw (master) 1
htmlcss1.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
20#include <hintids.hxx>
21#include <svl/itemiter.hxx>
22#include <svl/urihelper.hxx>
24#include <sfx2/docfile.hxx>
25#include <editeng/editids.hrc>
26#include <editeng/fhgtitem.hxx>
27#include <editeng/brushitem.hxx>
28#include <editeng/lrspitem.hxx>
29#include <editeng/ulspitem.hxx>
30#include <editeng/boxitem.hxx>
31#include <editeng/flstitem.hxx>
33#include <editeng/keepitem.hxx>
34#include <editeng/fontitem.hxx>
35#include <editeng/langitem.hxx>
37#include <o3tl/string_view.hxx>
38#include <svtools/htmltokn.h>
39#include <svtools/htmlkywd.hxx>
40#include <fmtpdsc.hxx>
41#include <fmtanchr.hxx>
42#include <fmtornt.hxx>
43#include <fmtsrnd.hxx>
44#include <fmtfsize.hxx>
45#include <frmatr.hxx>
46#include <charfmt.hxx>
47#include <docary.hxx>
48#include <osl/diagnose.h>
49
50#include <doc.hxx>
52#include <pam.hxx>
53#include <poolfmt.hxx>
54#include <docsh.hxx>
55#include <paratr.hxx>
56#include <pagedesc.hxx>
57#include "css1kywd.hxx"
58#include "swcss1.hxx"
59#include "htmlnum.hxx"
60#include "swhtml.hxx"
61#include <numrule.hxx>
62#include "css1atr.hxx"
63
64using namespace ::com::sun::star;
65
66// How many rows/characters are allowed for DropCaps?
67// (Are there maybe somewhere else corresponding values?)
68#define MAX_DROPCAP_LINES 9
69#define MAX_DROPCAP_CHARS 9
70
71static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc );
72
73// Implementation of SwCSS1Parsers (actually swcss1.cxx)
74const sal_uInt16 aItemIds[] =
75{
79};
80
82 const SwPageDesc& rNewPageDesc )
83{
84 size_t pos;
85 bool found = m_pDoc->ContainsPageDesc( pPageDesc, &pos );
86 OSL_ENSURE( found, "style not found" );
87 if (found)
88 m_pDoc->ChgPageDesc( pos, rNewPageDesc );
89}
90
91SwCSS1Parser::SwCSS1Parser(SwDoc *const pDoc, SwHTMLParser const& rParser,
92 const sal_uInt32 aFHeights[7], const OUString& rBaseURL, bool const bNewDoc)
93 : SvxCSS1Parser(pDoc->GetAttrPool(), rBaseURL,
95 , m_pDoc( pDoc )
96 , m_rHTMLParser(rParser)
97 , m_nDropCapCnt( 0 ),
98 m_bIsNewDoc( bNewDoc ),
99 m_bBodyBGColorSet( false ),
100 m_bBodyBackgroundSet( false ),
101 m_bBodyTextSet( false ),
102 m_bBodyLinkSet( false ),
103 m_bBodyVLinkSet( false ),
104 m_bSetFirstPageDesc( false ),
105 m_bSetRightPageDesc( false ),
106 m_bTableHeaderTextCollSet( false ),
107 m_bTableTextCollSet( false ),
108 m_bLinkCharFormatsSet( false )
109{
110 m_aFontHeights[0] = aFHeights[0];
111 m_aFontHeights[1] = aFHeights[1];
112 m_aFontHeights[2] = aFHeights[2];
113 m_aFontHeights[3] = aFHeights[3];
114 m_aFontHeights[4] = aFHeights[4];
115 m_aFontHeights[5] = aFHeights[5];
116 m_aFontHeights[6] = aFHeights[6];
117}
118
120{
121}
122
123// Feature: PrintExt
125 const SvxCSS1PropertyInfo& rPropInfo )
126{
127 SvxBreak eBreak = SvxBreak::NONE;
128 bool bKeep = false;
129 bool bSetKeep = false, bSetBreak = false, bSetPageDesc = false;
130 const SwPageDesc *pPageDesc = nullptr;
131 switch( rPropInfo.m_ePageBreakBefore )
132 {
134 eBreak = SvxBreak::PageBefore;
135 bSetBreak = true;
136 break;
138 pPageDesc = GetLeftPageDesc( true );
139 bSetPageDesc = true;
140 break;
142 pPageDesc = GetRightPageDesc( true );
143 bSetPageDesc = true;
144 break;
146 bSetBreak = bSetPageDesc = true;
147 break;
148 default:
149 ;
150 }
151 switch( rPropInfo.m_ePageBreakAfter )
152 {
156 // LEFT/RIGHT also could be set in the previous paragraph
157 eBreak = SvxBreak::PageAfter;
158 bSetBreak = true;
159 break;
161 bSetBreak = bSetKeep = bSetPageDesc = true;
162 break;
164 bKeep = bSetKeep = true;
165 break;
166 default:
167 ;
168 }
169
170 if( bSetBreak )
171 rItemSet.Put( SvxFormatBreakItem( eBreak, RES_BREAK ) );
172 if( bSetPageDesc )
173 rItemSet.Put( SwFormatPageDesc( pPageDesc ) );
174 if( bSetKeep )
175 rItemSet.Put( SvxFormatKeepItem( bKeep, RES_KEEP ) );
176
177 return bSetBreak;
178}
179
180static void SetCharFormatAttrs( SwCharFormat *pCharFormat, SfxItemSet& rItemSet )
181{
184 for(auto const & i : aWhichIds)
185 {
186 const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( i, false );
187 if( pItem && pItem->GetProp() != 100)
188 {
189 // percentage values at the FontHeight item aren't supported
190 rItemSet.ClearItem( i );
191 }
192 }
193
194 pCharFormat->SetFormatAttr( rItemSet );
195
196 if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
197 {
198 // A Brush-Item with RES_BACKGROUND must be converted to one
199 // with RES_CHRATR_BACKGROUND
200
201 SvxBrushItem aBrushItem( *pItem );
202 aBrushItem.SetWhich( RES_CHRATR_BACKGROUND );
203 pCharFormat->SetFormatAttr( aBrushItem );
204 }
205
206 if( const SvxBoxItem* pItem = rItemSet.GetItemIfSet( RES_BOX, false ) )
207 {
208 SvxBoxItem aBoxItem( *pItem );
209 aBoxItem.SetWhich( RES_CHRATR_BOX );
210 pCharFormat->SetFormatAttr( aBoxItem );
211 }
212}
213
215{
216 OSL_ENSURE( !m_bLinkCharFormatsSet, "Call SetLinkCharFormats unnecessary" );
217
218 SvxCSS1MapEntry *pStyleEntry =
220 SwCharFormat *pUnvisited = nullptr, *pVisited = nullptr;
221 if( pStyleEntry )
222 {
223 SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
224 bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
225 false));
227 SetCharFormatAttrs( pUnvisited, rItemSet );
228 m_bBodyLinkSet |= bColorSet;
229
231 SetCharFormatAttrs( pVisited, rItemSet );
232 m_bBodyVLinkSet |= bColorSet;
233 }
234
235 OUString sTmp = OOO_STRING_SVTOOLS_HTML_anchor ":link";
236
237 pStyleEntry = GetTag( sTmp );
238 if( pStyleEntry )
239 {
240 SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
241 bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
242 false));
243 if( !pUnvisited )
245 SetCharFormatAttrs( pUnvisited, rItemSet );
246 m_bBodyLinkSet |= bColorSet;
247 }
248
249 sTmp = OOO_STRING_SVTOOLS_HTML_anchor ":visited";
250
251 pStyleEntry = GetTag( sTmp );
252 if( pStyleEntry )
253 {
254 SfxItemSet& rItemSet = pStyleEntry->GetItemSet();
255 bool bColorSet = (SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,
256 false));
257 if( !pVisited )
259 SetCharFormatAttrs( pVisited, rItemSet );
260 m_bBodyVLinkSet |= bColorSet;
261 }
262
264}
265
266static void SetTextCollAttrs( SwTextFormatColl *pColl, SfxItemSet& rItemSet,
267 SvxCSS1PropertyInfo const & rPropInfo,
268 SwCSS1Parser *pCSS1Parser )
269{
270 const SfxItemSet& rCollItemSet = pColl->GetAttrSet();
271
272 // note: there was some SvxLRSpaceItem code here that was nonobvious
273 // but it looks like the only cases in which it would be required
274 // with split items are if some nProp != 100 or if SetAutoFirst() had
275 // been called (on the pColl items) but it looks like none of these are
276 // possible in HTML import.
277
278 // top and bottom border
279 const SvxULSpaceItem* pCollULItem;
280 const SvxULSpaceItem* pULItem;
281 if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
282 (!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
283 (pCollULItem = rCollItemSet.GetItemIfSet(RES_UL_SPACE)) &&
284 (pULItem = rItemSet.GetItemIfSet(RES_UL_SPACE,false)) )
285 {
286 SvxULSpaceItem aULItem( *pCollULItem );
287 if( rPropInfo.m_bTopMargin )
288 aULItem.SetUpper( pULItem->GetUpper() );
289 if( rPropInfo.m_bBottomMargin )
290 aULItem.SetLower( pULItem->GetLower() );
291
292 rItemSet.Put( aULItem );
293 }
294
297 for(auto const & i : aWhichIds)
298 {
299 const SvxFontHeightItem* pItem = rItemSet.GetItemIfSet( i, false );
300 if( pItem && pItem->GetProp() != 100)
301 {
302 // percentage values at the FontHeight item aren't supported
303 rItemSet.ClearItem( i );
304 }
305 }
306
307 pCSS1Parser->SetFormatBreak( rItemSet, rPropInfo );
308
309 pColl->SetFormatAttr( rItemSet );
310}
311
313{
314 OSL_ENSURE( !(bHeader ? m_bTableHeaderTextCollSet : m_bTableTextCollSet),
315 "Call SetTableTextColl unnecessary" );
316
317 sal_uInt16 nPoolId;
318 OUString sTag;
319 if( bHeader )
320 {
321 nPoolId = RES_POOLCOLL_TABLE_HDLN;
323 }
324 else
325 {
326 nPoolId = RES_POOLCOLL_TABLE;
328 }
329
330 SwTextFormatColl *pColl = nullptr;
331
332 // The following entries will never be used again and may be changed.
333 SvxCSS1MapEntry *pStyleEntry = GetTag( sTag );
334 if( pStyleEntry )
335 {
336 pColl = GetTextFormatColl(nPoolId, OUString());
337 SetTextCollAttrs( pColl, pStyleEntry->GetItemSet(),
338 pStyleEntry->GetPropertyInfo(), this );
339 }
340
341 OUString sTmp = sTag + " " OOO_STRING_SVTOOLS_HTML_parabreak;
342 pStyleEntry = GetTag( sTmp );
343 if( pStyleEntry )
344 {
345 if( !pColl )
346 pColl = GetTextFormatColl(nPoolId, OUString());
347 SetTextCollAttrs( pColl, pStyleEntry->GetItemSet(),
348 pStyleEntry->GetPropertyInfo(), this );
349 }
350
351 if( bHeader )
353 else
354 m_bTableTextCollSet = true;
355}
356
358 SfxItemSet *pItemSet2 )
359{
360 std::shared_ptr<SvxBrushItem> aBrushItem(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
361 std::shared_ptr<SvxBoxItem> aBoxItem(std::make_shared<SvxBoxItem>(RES_BOX));
362 std::shared_ptr<SvxFrameDirectionItem> aFrameDirItem(std::make_shared<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR));
363 bool bSetBrush = pBrush!=nullptr, bSetBox = false, bSetFrameDir = false;
364 if( pBrush )
365 aBrushItem.reset(pBrush->Clone());
366
367 if( pItemSet2 )
368 {
369 if( const SvxBrushItem* pItem = pItemSet2->GetItemIfSet( RES_BACKGROUND, false ) )
370 {
371 // set a background
372 aBrushItem.reset(pItem->Clone());
373 pItemSet2->ClearItem( RES_BACKGROUND );
374 bSetBrush = true;
375 }
376
377 if( const SvxBoxItem* pItem = pItemSet2->GetItemIfSet( RES_BOX, false ) )
378 {
379 // set a border
380 aBoxItem.reset(pItem->Clone());
381 pItemSet2->ClearItem( RES_BOX );
382 bSetBox = true;
383 }
384
385 if( const SvxFrameDirectionItem* pItem = pItemSet2->GetItemIfSet( RES_FRAMEDIR, false ) )
386 {
387 // set a frame
388 aFrameDirItem.reset(pItem->Clone());
389 pItemSet2->ClearItem( RES_FRAMEDIR );
390 bSetFrameDir = true;
391 }
392 }
393
394 if( !(bSetBrush || bSetBox || bSetFrameDir) )
395 return;
396
397 static sal_uInt16 aPoolIds[] = { RES_POOLPAGE_HTML, RES_POOLPAGE_FIRST,
399 for(sal_uInt16 i : aPoolIds)
400 {
401 const SwPageDesc *pPageDesc = GetPageDesc( i, false );
402 if( pPageDesc )
403 {
404 SwPageDesc aNewPageDesc( *pPageDesc );
405 SwFrameFormat &rMaster = aNewPageDesc.GetMaster();
406 if( bSetBrush )
407 rMaster.SetFormatAttr( *aBrushItem );
408 if( bSetBox )
409 rMaster.SetFormatAttr( *aBoxItem );
410 if( bSetFrameDir )
411 rMaster.SetFormatAttr( *aFrameDirItem );
412
413 ChgPageDesc( pPageDesc, aNewPageDesc );
414 }
415 }
416}
417
418// Feature: PrintExt
420 SfxItemSet& rItemSet,
421 const SvxCSS1PropertyInfo& rPropInfo )
422{
423 if( !pPageDesc )
424 return;
425
426 SwPageDesc aNewPageDesc( *pPageDesc );
427 SwFrameFormat &rMaster = aNewPageDesc.GetMaster();
428 const SfxItemSet& rPageItemSet = rMaster.GetAttrSet();
429 bool bChanged = false;
430
431 // left, right border and first line indentation
432 ::std::optional<SvxLRSpaceItem> oLRSpace;
433 assert(!rItemSet.GetItemIfSet(RES_LR_SPACE,false));
434 if (rPropInfo.m_bLeftMargin)
435 {
436 // note: parser never creates SvxLeftMarginItem! must be converted
437 if (SvxTextLeftMarginItem const*const pLeft = rItemSet.GetItemIfSet(RES_MARGIN_TEXTLEFT, false))
438 {
439 if (!oLRSpace)
440 {
441 if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE))
442 {
443 oLRSpace.emplace(*pPageItem);
444 }
445 else
446 {
447 oLRSpace.emplace(RES_LR_SPACE);
448 }
449 }
450 oLRSpace->SetLeft(pLeft->GetTextLeft());
451 }
452 }
453 if (rPropInfo.m_bRightMargin)
454 {
455 // note: parser never creates SvxLeftMarginItem! must be converted
456 if (SvxRightMarginItem const*const pRight = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false))
457 {
458 if (!oLRSpace)
459 {
460 if (const SvxLRSpaceItem* pPageItem = rPageItemSet.GetItemIfSet(RES_LR_SPACE))
461 {
462 oLRSpace.emplace(*pPageItem);
463 }
464 else
465 {
466 oLRSpace.emplace(RES_LR_SPACE);
467 }
468 }
469 oLRSpace->SetRight(pRight->GetRight());
470 }
471 }
472 if (oLRSpace)
473 {
474 rMaster.SetFormatAttr(*oLRSpace);
475 bChanged = true;
476 }
477
478 // top and bottom border
479 const SvxULSpaceItem *pULItem;
480 if( (rPropInfo.m_bTopMargin || rPropInfo.m_bBottomMargin) &&
481 (pULItem = rItemSet.GetItemIfSet(RES_UL_SPACE,false)) )
482 {
483 const SvxULSpaceItem* pPageItem;
484 if( (!rPropInfo.m_bTopMargin || !rPropInfo.m_bBottomMargin) &&
485 (pPageItem = rPageItemSet.GetItemIfSet(RES_UL_SPACE) ) )
486 {
487 SvxULSpaceItem aULItem( *pPageItem );
488 if( rPropInfo.m_bTopMargin )
489 aULItem.SetUpper( pULItem->GetUpper() );
490 if( rPropInfo.m_bBottomMargin )
491 aULItem.SetLower( pULItem->GetLower() );
492
493 rMaster.SetFormatAttr( aULItem );
494 }
495 else
496 {
497 rMaster.SetFormatAttr( *pULItem );
498 }
499 bChanged = true;
500 }
501
502 // the size
503 if( rPropInfo.m_eSizeType != SVX_CSS1_STYPE_NONE )
504 {
505 if( rPropInfo.m_eSizeType == SVX_CSS1_STYPE_TWIP )
506 {
508 rPropInfo.m_nHeight ) );
509 bChanged = true;
510 }
511 else
512 {
513 // With "size: auto|portrait|landscape" the current size
514 // of the style remains. If "landscape" and "portrait" then
515 // the landscape flag will be set and maybe the width/height
516 // are swapped.
517 SwFormatFrameSize aFrameSz( rMaster.GetFrameSize() );
518 bool bLandscape = aNewPageDesc.GetLandscape();
519 if( ( bLandscape &&
520 rPropInfo.m_eSizeType == SVX_CSS1_STYPE_PORTRAIT ) ||
521 ( !bLandscape &&
523 {
524 SwTwips nTmp = aFrameSz.GetHeight();
525 aFrameSz.SetHeight( aFrameSz.GetWidth() );
526 aFrameSz.SetWidth( nTmp );
527 rMaster.SetFormatAttr( aFrameSz );
528 aNewPageDesc.SetLandscape( !bLandscape );
529 bChanged = true;
530 }
531 }
532 }
533
534 // Is that possible?
535 if( const SvxBrushItem* pItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false ) )
536 {
537 // set a background
538 rMaster.SetFormatAttr( *pItem );
539 rItemSet.ClearItem( RES_BACKGROUND );
540 bChanged = true;
541 }
542
543 if( bChanged )
544 ChgPageDesc( pPageDesc, aNewPageDesc );
545}
546
547std::unique_ptr<SvxBrushItem> SwCSS1Parser::makePageDescBackground() const
548{
551}
552
554 bool bSubClassOnly )
555{
557 sal_Int32 nLen = rClass.getLength();
558 sal_Int32 nPos = nLen > 4 ? rClass.lastIndexOf( '-' ) : -1;
559
560 if( nPos == -1 )
561 {
562 if( bSubClassOnly )
563 return nScriptFlags;
564 nPos = 0;
565 }
566 else
567 {
568 nPos++;
569 nLen = nLen - nPos;
570 }
571
572 switch( nLen )
573 {
574 case 3:
575 if( rClass.matchIgnoreAsciiCase( "cjk", nPos ) )
576 {
577 nScriptFlags = Css1ScriptFlags::CJK;
578 }
579 else if( rClass.matchIgnoreAsciiCase( "ctl", nPos ) )
580 {
581 nScriptFlags = Css1ScriptFlags::CTL;
582 }
583 break;
584 case 7:
585 if( rClass.matchIgnoreAsciiCase( "western", nPos ) )
586 {
587 nScriptFlags = Css1ScriptFlags::Western;
588 }
589 break;
590 }
591 if( Css1ScriptFlags::AllMask != nScriptFlags )
592 {
593 if( nPos )
594 {
595 rClass = rClass.copy( 0, nPos-1 );
596 }
597 else
598 {
599 rClass.clear();
600 }
601 }
602
603 return nScriptFlags;
604}
605
607 OUString& rToken, OUString& rClass,
608 Css1ScriptFlags& rScriptFlags )
609{
610 rToken = pSelector->GetString();
611 rClass.clear();
612 rScriptFlags = Css1ScriptFlags::AllMask;
613
614 CSS1SelectorType eType = pSelector->GetType();
616 {
617 sal_Int32 nPos = rToken.indexOf( '.' );
618 OSL_ENSURE( nPos >= 0, "No dot in Class-Selector???" );
619 if( nPos >= 0 )
620 {
621 rClass = rToken.copy( nPos+1 );
622 rToken = rToken.copy( 0, nPos );
623
624 rScriptFlags = SwCSS1Parser::GetScriptFromClass( rClass, false );
625 if( rClass.isEmpty() )
627 }
628 }
629
630 rToken = rToken.toAsciiLowerCase();
631 return eType;
632}
633
634static void RemoveScriptItems( SfxItemSet& rItemSet, Css1ScriptFlags nScript,
635 const SfxItemSet *pParentItemSet = nullptr )
636{
637 static const sal_uInt16 aWhichIds[3][5] =
638 {
645 };
646
647 bool aClearItems[3] = { false, false, false };
648 switch( nScript )
649 {
651 aClearItems[1] = aClearItems[2] = true;
652 break;
654 aClearItems[0] = aClearItems[2] = true;
655 break;
657 aClearItems[0] = aClearItems[1] = true;
658 break;
660 break;
661 default:
662 OSL_ENSURE( aClearItems[0], "unknown script type" );
663 break;
664 }
665
666 for( size_t j=0; j < SAL_N_ELEMENTS(aWhichIds); ++j )
667 {
668 for( size_t i=0; i < SAL_N_ELEMENTS(aWhichIds[0]); ++i )
669 {
670 sal_uInt16 nWhich = aWhichIds[j][i];
671 const SfxPoolItem *pItem;
672 if( aClearItems[j] ||
673 (pParentItemSet &&
674 SfxItemState::SET == rItemSet.GetItemState( nWhich, false, &pItem ) &&
675 (0==i ? swhtml_css1atr_equalFontItems( *pItem, pParentItemSet->Get(nWhich ) )
676 : *pItem == pParentItemSet->Get(nWhich ) ) ) )
677 {
678 rItemSet.ClearItem( nWhich );
679 }
680 }
681 }
682}
683
685 SfxItemSet& rItemSet,
686 SvxCSS1PropertyInfo& rPropInfo )
687{
688 if( !m_bIsNewDoc )
689 return;
690
691 CSS1SelectorType eSelType = pSelector->GetType();
692 const CSS1Selector *pNext = pSelector->GetNext();
693
694 if( CSS1_SELTYPE_ID==eSelType && !pNext )
695 {
696 InsertId( pSelector->GetString(), rItemSet, rPropInfo );
697 }
698 else if( CSS1_SELTYPE_CLASS==eSelType && !pNext )
699 {
700 OUString aClass( pSelector->GetString() );
701 Css1ScriptFlags nScript = GetScriptFromClass( aClass );
702 if( Css1ScriptFlags::AllMask != nScript )
703 {
704 SfxItemSet aScriptItemSet( rItemSet );
705 RemoveScriptItems( aScriptItemSet, nScript );
706 InsertClass( aClass, aScriptItemSet, rPropInfo );
707 }
708 else
709 {
710 InsertClass( aClass, rItemSet, rPropInfo );
711 }
712 }
713 else if( CSS1_SELTYPE_PAGE==eSelType )
714 {
715 if( !pNext ||
716 (CSS1_SELTYPE_PSEUDO == pNext->GetType() &&
717 (pNext->GetString().equalsIgnoreAsciiCase( "left" ) ||
718 pNext->GetString().equalsIgnoreAsciiCase( "right" ) ||
719 pNext->GetString().equalsIgnoreAsciiCase( "first" ) ) ) )
720 {
721 OUString aName;
722 if( pNext )
723 aName = pNext->GetString();
725 pNext != nullptr,
726 rItemSet, rPropInfo );
727 }
728 }
729
730 if( CSS1_SELTYPE_ELEMENT != eSelType &&
731 CSS1_SELTYPE_ELEM_CLASS != eSelType)
732 return;
733
734 // get token and class of selector
735 OUString aToken2;
736 OUString aClass;
737 Css1ScriptFlags nScript;
738 eSelType = GetTokenAndClass( pSelector, aToken2, aClass, nScript );
739 HtmlTokenId nToken2 = GetHTMLToken( aToken2 );
740
741 // and also some information of the next element
742 CSS1SelectorType eNextType = pNext ? pNext->GetType()
744
745 // first some special cases
746 if( CSS1_SELTYPE_ELEMENT==eSelType )
747 {
748 switch( nToken2 )
749 {
750 case HtmlTokenId::ANCHOR_ON:
751 if( !pNext )
752 {
753 InsertTag( aToken2, rItemSet, rPropInfo );
754 return;
755 }
756 else if (CSS1_SELTYPE_PSEUDO == eNextType)
757 {
758 // maybe A:visited or A:link
759
760 OUString aPseudo( pNext->GetString() );
761 aPseudo = aPseudo.toAsciiLowerCase();
762 bool bInsert = false;
763 switch( aPseudo[0] )
764 {
765 case 'l':
766 if( aPseudo == "link" )
767 {
768 bInsert = true;
769 }
770 break;
771 case 'v':
772 if( aPseudo == "visited" )
773 {
774 bInsert = true;
775 }
776 break;
777 }
778 if( bInsert )
779 {
780 OUString sTmp = aToken2 + ":" + aPseudo;
781 if( Css1ScriptFlags::AllMask != nScript )
782 {
783 SfxItemSet aScriptItemSet( rItemSet );
784 RemoveScriptItems( aScriptItemSet, nScript );
785 InsertTag( sTmp, aScriptItemSet, rPropInfo );
786 }
787 else
788 {
789 InsertTag( sTmp, rItemSet, rPropInfo );
790 }
791 return;
792 }
793 }
794 break;
795 case HtmlTokenId::BODY_ON:
796 if( !pNext )
797 {
798 // BODY
799
800 // We must test the background before setting, because
801 // in SetPageDescAttrs it will be deleted.
802 if( const SvxBrushItem *pBrushItem = rItemSet.GetItemIfSet(RES_BACKGROUND,false) )
803 {
805 if( pBrushItem->GetColor() != COL_TRANSPARENT )
806 m_bBodyBGColorSet = true;
807 if( GPOS_NONE != pBrushItem->GetGraphicPos() )
809 }
810
811 // Border and Padding
812 rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
813
814 // Some attributes must be set at the style, the ones which
815 // aren't inherited
816 SetPageDescAttrs( nullptr, &rItemSet );
817
818 // all remaining options can be set at the default style,
819 // then they're the default
820 if( SfxItemState::SET==rItemSet.GetItemState(RES_CHRATR_COLOR,false) )
821 m_bBodyTextSet = true;
824 rItemSet, rPropInfo, this );
825
826 return;
827 }
828 break;
829 default: break;
830 }
831 }
832 else if( CSS1_SELTYPE_ELEM_CLASS==eSelType && HtmlTokenId::ANCHOR_ON==nToken2 &&
833 !pNext && aClass.getLength() >= 9 &&
834 ('s' == aClass[0] || 'S' == aClass[0]) )
835 {
836 sal_uInt16 nPoolFormatId = 0;
837 if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote_sym) )
838 nPoolFormatId = RES_POOLCHR_ENDNOTE;
839 else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote_sym) )
840 nPoolFormatId = RES_POOLCHR_FOOTNOTE;
841 if( nPoolFormatId )
842 {
843 if( Css1ScriptFlags::AllMask == nScript )
844 {
845 SetCharFormatAttrs( GetCharFormatFromPool(nPoolFormatId), rItemSet );
846 }
847 else
848 {
849 SfxItemSet aScriptItemSet( rItemSet );
850 RemoveScriptItems( aScriptItemSet, nScript );
852 aScriptItemSet);
853 }
854 return;
855 }
856 }
857
858 // Now the selectors are processed which belong to a paragraph style
859 sal_uInt16 nPoolCollId = 0;
860 switch( nToken2 )
861 {
862 case HtmlTokenId::HEAD1_ON:
863 nPoolCollId = RES_POOLCOLL_HEADLINE1;
864 break;
865 case HtmlTokenId::HEAD2_ON:
866 nPoolCollId = RES_POOLCOLL_HEADLINE2;
867 break;
868 case HtmlTokenId::HEAD3_ON:
869 nPoolCollId = RES_POOLCOLL_HEADLINE3;
870 break;
871 case HtmlTokenId::HEAD4_ON:
872 nPoolCollId = RES_POOLCOLL_HEADLINE4;
873 break;
874 case HtmlTokenId::HEAD5_ON:
875 nPoolCollId = RES_POOLCOLL_HEADLINE5;
876 break;
877 case HtmlTokenId::HEAD6_ON:
878 nPoolCollId = RES_POOLCOLL_HEADLINE6;
879 break;
880 case HtmlTokenId::PARABREAK_ON:
881 if( aClass.getLength() >= 9 &&
882 ('s' == aClass[0] || 'S' == aClass[0]) )
883 {
884 if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote) )
885 nPoolCollId = RES_POOLCOLL_ENDNOTE;
886 else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
887 nPoolCollId = RES_POOLCOLL_FOOTNOTE;
888
889 if( nPoolCollId )
890 aClass.clear();
891 else
892 nPoolCollId = RES_POOLCOLL_TEXT;
893 }
894 else
895 {
896 nPoolCollId = RES_POOLCOLL_TEXT;
897 }
898 break;
899 case HtmlTokenId::ADDRESS_ON:
900 nPoolCollId = RES_POOLCOLL_SEND_ADDRESS;
901 break;
902 case HtmlTokenId::BLOCKQUOTE_ON:
903 nPoolCollId = RES_POOLCOLL_HTML_BLOCKQUOTE;
904 break;
905 case HtmlTokenId::DT_ON:
906 nPoolCollId = RES_POOLCOLL_HTML_DT;
907 break;
908 case HtmlTokenId::DD_ON:
909 nPoolCollId = RES_POOLCOLL_HTML_DD;
910 break;
911 case HtmlTokenId::PREFORMTXT_ON:
912 nPoolCollId = RES_POOLCOLL_HTML_PRE;
913 break;
914 case HtmlTokenId::TABLEHEADER_ON:
915 case HtmlTokenId::TABLEDATA_ON:
916 if( CSS1_SELTYPE_ELEMENT==eSelType && !pNext )
917 {
918 InsertTag( aToken2, rItemSet, rPropInfo );
919 return;
920 }
921 else if( CSS1_SELTYPE_ELEMENT==eSelType && pNext &&
922 (CSS1_SELTYPE_ELEMENT==eNextType ||
923 CSS1_SELTYPE_ELEM_CLASS==eNextType) )
924 {
925 // not TH and TD, but TH P and TD P
926 OUString aSubToken, aSubClass;
927 GetTokenAndClass( pNext, aSubToken, aSubClass, nScript );
928 if( HtmlTokenId::PARABREAK_ON == GetHTMLToken( aSubToken ) )
929 {
930 aClass = aSubClass;
931 pNext = pNext->GetNext();
932 eNextType = pNext ? pNext->GetType() : CSS1_SELTYPE_ELEMENT;
933
934 if( !aClass.isEmpty() || pNext )
935 {
936 nPoolCollId = static_cast< sal_uInt16 >(
937 HtmlTokenId::TABLEHEADER_ON == nToken2 ? RES_POOLCOLL_TABLE_HDLN
939 }
940 else
941 {
942 OUString sTmp = aToken2 + " " OOO_STRING_SVTOOLS_HTML_parabreak;
943
944 if( Css1ScriptFlags::AllMask == nScript )
945 {
946 InsertTag( sTmp, rItemSet, rPropInfo );
947 }
948 else
949 {
950 SfxItemSet aScriptItemSet( rItemSet );
951 RemoveScriptItems( aScriptItemSet, nScript );
952 InsertTag( sTmp, aScriptItemSet, rPropInfo );
953 }
954
955 return;
956 }
957 }
958 }
959 break;
960
961 default:
962 ;
963 }
964
965 if( nPoolCollId )
966 {
967 if( !pNext ||
968 (CSS1_SELTYPE_PSEUDO==eNextType &&
969 pNext->GetString().equalsIgnoreAsciiCase( "first-letter" ) &&
970 SvxAdjust::Left == rPropInfo.m_eFloat) )
971 {
972 // either not a composed selector or a X:first-line { float: left; ... }
973
974 // search resp. create the style
975 SwTextFormatColl* pColl = GetTextFormatColl(nPoolCollId, OUString());
976 SwTextFormatColl* pParentColl = nullptr;
977 if( !aClass.isEmpty() )
978 {
979 OUString aName( pColl->GetName() );
980 AddClassName( aName, aClass );
981
982 pParentColl = pColl;
984 if( !pColl )
985 pColl = m_pDoc->MakeTextFormatColl( aName, pParentColl );
986 }
987 if( !pNext )
988 {
989 // set only the attributes at the style
990 const SvxBoxItem *pBoxItem =
992 rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST, pBoxItem );
993 if( Css1ScriptFlags::AllMask == nScript && !pParentColl )
994 {
995 SetTextCollAttrs( pColl, rItemSet, rPropInfo, this );
996 }
997 else
998 {
999 SfxItemSet aScriptItemSet( rItemSet );
1000 RemoveScriptItems( aScriptItemSet, nScript,
1001 pParentColl ? &pParentColl->GetAttrSet() : nullptr );
1002 SetTextCollAttrs( pColl, aScriptItemSet, rPropInfo, this );
1003 }
1004 }
1005 else
1006 {
1007 // create a DropCap attribute
1008 SwFormatDrop aDrop( pColl->GetDrop() );
1009 aDrop.GetChars() = 1;
1010
1011 // set the attributes of the DropCap attribute
1012 if( Css1ScriptFlags::AllMask == nScript )
1013 {
1014 OUString sName(pColl->GetName());
1015 FillDropCap( aDrop, rItemSet, &sName );
1016 }
1017 else
1018 {
1019 SfxItemSet aScriptItemSet( rItemSet );
1020 if( Css1ScriptFlags::Western != nScript )
1021 {
1022 aScriptItemSet.ClearItem( RES_CHRATR_FONT );
1023 aScriptItemSet.ClearItem( RES_CHRATR_LANGUAGE );
1024 aScriptItemSet.ClearItem( RES_CHRATR_POSTURE );
1025 aScriptItemSet.ClearItem( RES_CHRATR_WEIGHT );
1026 }
1027 if( Css1ScriptFlags::CJK != nScript )
1028 {
1029 aScriptItemSet.ClearItem( RES_CHRATR_CJK_FONT );
1030 aScriptItemSet.ClearItem( RES_CHRATR_CJK_LANGUAGE );
1031 aScriptItemSet.ClearItem( RES_CHRATR_CJK_POSTURE );
1032 aScriptItemSet.ClearItem( RES_CHRATR_CJK_WEIGHT );
1033 }
1034 if( Css1ScriptFlags::CTL != nScript )
1035 {
1036 aScriptItemSet.ClearItem( RES_CHRATR_CTL_FONT );
1037 aScriptItemSet.ClearItem( RES_CHRATR_CTL_LANGUAGE );
1038 aScriptItemSet.ClearItem( RES_CHRATR_CTL_POSTURE );
1039 aScriptItemSet.ClearItem( RES_CHRATR_CTL_WEIGHT );
1040 }
1041 OUString sName(pColl->GetName());
1042 FillDropCap( aDrop, aScriptItemSet, &sName );
1043 }
1044
1045 // Only set the attribute if "float: left" is specified and
1046 // the Initial is over several lines. Otherwise the maybe
1047 // created character style will be later searched and set
1048 // via name.
1049 if( aDrop.GetLines() > 1 &&
1050 (SvxAdjust::Left == rPropInfo.m_eFloat ||
1051 Css1ScriptFlags::AllMask == nScript) )
1052 {
1053 pColl->SetFormatAttr( aDrop );
1054 }
1055 }
1056 }
1057
1058 return;
1059 }
1060
1061 // Now the selectors are processed which are belonging to the character
1062 // template. There are no composed ones here.
1063 if( pNext )
1064 return;
1065
1066 SwCharFormat* pCFormat = GetChrFormat(nToken2, OUString());
1067 if( !pCFormat )
1068 return;
1069
1070 SwCharFormat *pParentCFormat = nullptr;
1071 if( !aClass.isEmpty() )
1072 {
1073 OUString aName( pCFormat->GetName() );
1074 AddClassName( aName, aClass );
1075 pParentCFormat = pCFormat;
1076
1077 pCFormat = m_pDoc->FindCharFormatByName( aName );
1078 if( !pCFormat )
1079 {
1080 pCFormat = m_pDoc->MakeCharFormat( aName, pParentCFormat );
1081 pCFormat->SetAuto(false);
1082 }
1083 }
1084
1085 if( Css1ScriptFlags::AllMask == nScript && !pParentCFormat )
1086 {
1087 SetCharFormatAttrs( pCFormat, rItemSet );
1088 }
1089 else
1090 {
1091 SfxItemSet aScriptItemSet( rItemSet );
1092 RemoveScriptItems( aScriptItemSet, nScript,
1093 pParentCFormat ? &pParentCFormat->GetAttrSet() : nullptr );
1094 SetCharFormatAttrs( pCFormat, aScriptItemSet );
1095 }
1096}
1097
1098sal_uInt32 SwCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
1099{
1100 return m_aFontHeights[ std::min<sal_uInt16>(nSize,6) ];
1101}
1102
1104{
1105 const FontList *pFList = nullptr;
1106 SwDocShell *pDocSh = m_pDoc->GetDocShell();
1107 if( pDocSh )
1108 {
1109 const SvxFontListItem *pFListItem =
1110 static_cast<const SvxFontListItem *>(pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
1111 if( pFListItem )
1112 pFList = pFListItem->GetFontList();
1113 }
1114
1115 return pFList;
1116}
1117
1118SwCharFormat* SwCSS1Parser::GetChrFormat( HtmlTokenId nToken2, const OUString& rClass ) const
1119{
1120 // search the corresponding style
1121 sal_uInt16 nPoolId = 0;
1122 const char* sName = nullptr;
1123 switch( nToken2 )
1124 {
1125 case HtmlTokenId::EMPHASIS_ON: nPoolId = RES_POOLCHR_HTML_EMPHASIS; break;
1126 case HtmlTokenId::CITATION_ON: nPoolId = RES_POOLCHR_HTML_CITATION; break;
1127 case HtmlTokenId::STRONG_ON: nPoolId = RES_POOLCHR_HTML_STRONG; break;
1128 case HtmlTokenId::CODE_ON: nPoolId = RES_POOLCHR_HTML_CODE; break;
1129 case HtmlTokenId::SAMPLE_ON: nPoolId = RES_POOLCHR_HTML_SAMPLE; break;
1130 case HtmlTokenId::KEYBOARD_ON: nPoolId = RES_POOLCHR_HTML_KEYBOARD; break;
1131 case HtmlTokenId::VARIABLE_ON: nPoolId = RES_POOLCHR_HTML_VARIABLE; break;
1132 case HtmlTokenId::DEFINSTANCE_ON: nPoolId = RES_POOLCHR_HTML_DEFINSTANCE; break;
1133 case HtmlTokenId::TELETYPE_ON: nPoolId = RES_POOLCHR_HTML_TELETYPE; break;
1134
1135 case HtmlTokenId::SHORTQUOTE_ON: sName = OOO_STRING_SVTOOLS_HTML_shortquote; break;
1136 case HtmlTokenId::LANGUAGE_ON: sName = OOO_STRING_SVTOOLS_HTML_language; break;
1137 case HtmlTokenId::AUTHOR_ON: sName = OOO_STRING_SVTOOLS_HTML_author; break;
1138 case HtmlTokenId::PERSON_ON: sName = OOO_STRING_SVTOOLS_HTML_person; break;
1139 case HtmlTokenId::ACRONYM_ON: sName = OOO_STRING_SVTOOLS_HTML_acronym; break;
1140 case HtmlTokenId::ABBREVIATION_ON: sName = OOO_STRING_SVTOOLS_HTML_abbreviation; break;
1141 case HtmlTokenId::INSERTEDTEXT_ON: sName = OOO_STRING_SVTOOLS_HTML_insertedtext; break;
1142 case HtmlTokenId::DELETEDTEXT_ON: sName = OOO_STRING_SVTOOLS_HTML_deletedtext; break;
1143 default: break;
1144 }
1145
1146 // search or create the style (only possible with name)
1147 if( !nPoolId && !sName )
1148 return nullptr;
1149
1150 // search or create style (without class)
1151 SwCharFormat *pCFormat = nullptr;
1152 if( nPoolId )
1153 {
1154 pCFormat = GetCharFormatFromPool( nPoolId );
1155 }
1156 else
1157 {
1158 OUString sCName( OUString::createFromAscii(sName) );
1159 pCFormat = m_pDoc->FindCharFormatByName( sCName );
1160 if( !pCFormat )
1161 {
1162 pCFormat = m_pDoc->MakeCharFormat( sCName, m_pDoc->GetDfltCharFormat() );
1163 pCFormat->SetAuto(false);
1164 }
1165 }
1166
1167 OSL_ENSURE( pCFormat, "No character style???" );
1168
1169 // If a class exists, then search for the class style but don't
1170 // create one.
1171 OUString aClass( rClass );
1172 GetScriptFromClass( aClass, false );
1173 if( !aClass.isEmpty() )
1174 {
1175 OUString aTmp( pCFormat->GetName() );
1176 AddClassName( aTmp, aClass );
1177 SwCharFormat *pClassCFormat = m_pDoc->FindCharFormatByName( aTmp );
1178 if( pClassCFormat )
1179 {
1180 pCFormat = pClassCFormat;
1181 }
1182 else
1183 {
1184 const SvxCSS1MapEntry *pClass = GetClass( aClass );
1185 if( pClass )
1186 {
1187 pCFormat = m_pDoc->MakeCharFormat( aTmp, pCFormat );
1188 pCFormat->SetAuto(false);
1189 SfxItemSet aItemSet( pClass->GetItemSet() );
1190 SetCharFormatAttrs( pCFormat, aItemSet );
1191 }
1192 }
1193 }
1194
1195 return pCFormat;
1196}
1197
1199{
1201
1203
1204 if( m_bIsNewDoc )
1205 {
1207 for( SwTextFormatColls::size_type i=nOldArrLen; i<nArrLen; ++i )
1209 GetDfltEncoding() );
1210 }
1211
1212 return pColl;
1213}
1214
1216{
1217 const SwCharFormats::size_type nOldArrLen = m_pDoc->GetCharFormats()->size();
1218
1220
1221 if( m_bIsNewDoc )
1222 {
1223 const SwCharFormats::size_type nArrLen = m_pDoc->GetCharFormats()->size();
1224
1225 for( SwCharFormats::size_type i=nOldArrLen; i<nArrLen; i++ )
1227 GetDfltEncoding() );
1228 }
1229
1230 return pCharFormat;
1231}
1232
1234 const OUString& rClass )
1235{
1236 SwTextFormatColl* pColl = nullptr;
1237
1238 OUString aClass( rClass );
1239 GetScriptFromClass( aClass, false );
1240 if( RES_POOLCOLL_TEXT == nTextColl && aClass.getLength() >= 9 &&
1241 ('s' == aClass[0] || 'S' == aClass[0] ) )
1242 {
1243 if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdendnote) )
1244 {
1245 nTextColl = RES_POOLCOLL_ENDNOTE;
1246 aClass.clear();
1247 }
1248 else if( aClass.equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_sdfootnote) )
1249 {
1250 nTextColl = RES_POOLCOLL_FOOTNOTE;
1251 aClass.clear();
1252 }
1253 }
1254
1255 if( USER_FMT & nTextColl ) // one created by Reader
1256 {
1257 OSL_ENSURE( false, "Where does the user style comes from?" );
1259 }
1260 else
1261 {
1262 pColl = GetTextCollFromPool( nTextColl );
1263 }
1264
1265 OSL_ENSURE( pColl, "No paragraph style???" );
1266 if( !aClass.isEmpty() )
1267 {
1268 OUString aTmp( pColl->GetName() );
1269 AddClassName( aTmp, aClass );
1270 SwTextFormatColl* pClassColl = m_pDoc->FindTextFormatCollByName( aTmp );
1271
1272 if( !pClassColl &&
1273 (nTextColl==RES_POOLCOLL_TABLE ||
1274 nTextColl==RES_POOLCOLL_TABLE_HDLN) )
1275 {
1276 // In this case there was a <TD><P CLASS=foo>, but no TD.foo
1277 // style was found. The we must use P.foo, if available.
1278 SwTextFormatColl* pCollText =
1280 aTmp = pCollText->GetName();
1281 AddClassName( aTmp, aClass );
1282 pClassColl = m_pDoc->FindTextFormatCollByName( aTmp );
1283 }
1284
1285 if( pClassColl )
1286 {
1287 pColl = pClassColl;
1288 }
1289 else
1290 {
1291 const SvxCSS1MapEntry *pClass = GetClass( aClass );
1292 if( pClass )
1293 {
1294 pColl = m_pDoc->MakeTextFormatColl( aTmp, pColl );
1295 SfxItemSet aItemSet( pClass->GetItemSet() );
1296 SvxCSS1PropertyInfo aPropInfo( pClass->GetPropertyInfo() );
1297 aPropInfo.SetBoxItem( aItemSet, MIN_BORDER_DIST );
1298 bool bPositioned = MayBePositioned( pClass->GetPropertyInfo() );
1299 if( bPositioned )
1300 aItemSet.ClearItem( RES_BACKGROUND );
1301 SetTextCollAttrs( pColl, aItemSet, aPropInfo,
1302 this );
1303 }
1304 }
1305
1306 }
1307
1308 if( pColl )
1310
1311 return pColl;
1312}
1313
1315{
1317}
1318
1319static SwPageDesc *FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
1320{
1321 size_t nPageDescs = pDoc->GetPageDescCnt();
1322 size_t nPage;
1323 for (nPage=0; nPage < nPageDescs &&
1324 pDoc->GetPageDesc(nPage).GetPoolFormatId() != nPoolId; ++nPage)
1325 ;
1326
1327 return nPage < nPageDescs ? &pDoc->GetPageDesc(nPage) : nullptr;
1328}
1329
1330const SwPageDesc *SwCSS1Parser::GetPageDesc( sal_uInt16 nPoolId, bool bCreate )
1331{
1332 if( RES_POOLPAGE_HTML == nPoolId )
1334
1335 const SwPageDesc *pPageDesc = FindPageDesc(m_pDoc, nPoolId);
1336 if( !pPageDesc && bCreate )
1337 {
1339 { // (there should be only one definition of header/footer in HTML)
1340 SAL_WARN("sw.html", "no creating PageDesc while reading header/footer");
1341 return nullptr;
1342 }
1343
1344 // The first page is created from the right page, if there is one.
1345 SwPageDesc *pMasterPageDesc = nullptr;
1346 if( RES_POOLPAGE_FIRST == nPoolId )
1347 pMasterPageDesc = FindPageDesc(m_pDoc, RES_POOLPAGE_RIGHT);
1348 if( !pMasterPageDesc )
1350
1351 // The new page style is created by copying from master
1352 SwPageDesc *pNewPageDesc = m_pDoc->
1353 getIDocumentStylePoolAccess().GetPageDescFromPool( nPoolId, false );
1354
1355 // therefore we also need the number of the new style
1356 OSL_ENSURE(pNewPageDesc == FindPageDesc(m_pDoc, nPoolId), "page style not found");
1357
1358 m_pDoc->CopyPageDesc( *pMasterPageDesc, *pNewPageDesc, false );
1359
1360 // Modify the styles for their new purpose.
1361 const SwPageDesc *pFollow = nullptr;
1362 bool bSetFollowFollow = false;
1363 switch( nPoolId )
1364 {
1365 case RES_POOLPAGE_FIRST:
1366 // If there is already a left page, then is it the follow-up
1367 // style, else it is the HTML style.
1368 pFollow = GetLeftPageDesc();
1369 if( !pFollow )
1370 pFollow = pMasterPageDesc;
1371 break;
1372
1373 case RES_POOLPAGE_RIGHT:
1374 // If the left style is already created, nothing will happen here.
1375 // Otherwise the left style is created and ensures the link with
1376 // the right style.
1377 GetLeftPageDesc( true );
1378 break;
1379
1380 case RES_POOLPAGE_LEFT:
1381 // The right style is created if none exists. No links are created.
1382 // If there is already a first page style, then the left style becomes
1383 // follow-up style of the first page.
1384 pFollow = GetRightPageDesc( true );
1385 bSetFollowFollow = true;
1386 {
1387 const SwPageDesc *pFirstPageDesc = GetFirstPageDesc();
1388 if( pFirstPageDesc )
1389 {
1390 SwPageDesc aNewFirstPageDesc( *pFirstPageDesc );
1391 aNewFirstPageDesc.SetFollow( pNewPageDesc );
1392 ChgPageDesc( pFirstPageDesc, aNewFirstPageDesc );
1393 }
1394 }
1395 break;
1396 }
1397
1398 if( pFollow )
1399 {
1400 SwPageDesc aNewPageDesc( *pNewPageDesc );
1401 aNewPageDesc.SetFollow( pFollow );
1402 ChgPageDesc( pNewPageDesc, aNewPageDesc );
1403
1404 if( bSetFollowFollow )
1405 {
1406 SwPageDesc aNewFollowPageDesc( *pFollow );
1407 aNewFollowPageDesc.SetFollow( pNewPageDesc );
1408 ChgPageDesc( pFollow, aNewFollowPageDesc );
1409 }
1410 }
1411 pPageDesc = pNewPageDesc;
1412 }
1413
1414 return pPageDesc;
1415}
1416
1418 bool bAutoWidth )
1419{
1420 if (!rPropInfo.m_bVisible)
1421 {
1422 // Don't create a textframe for this div if it's hidden.
1423 return false;
1424 }
1425
1426 // abs-pos
1427 // left/top none auto twip perc
1428
1429 // none Z Z - -
1430 // auto Z Z - -
1431 // twip Z Z S/R -
1432 // perc - - - -
1433
1434 // - the tag will be positioned absolutely and left/top are both
1435 // present and don't contain a percentage value, or
1436 // - the tag should flow, and
1437 // - a width was specified (needed in both cases)
1438 return ( ( SVX_CSS1_POS_ABSOLUTE == rPropInfo.m_ePosition &&
1441 (SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType ||
1442 SVX_CSS1_LTYPE_TWIP != rPropInfo.m_eTopType) ) ||
1443 ( SvxAdjust::End != rPropInfo.m_eFloat ) ) &&
1444 ( bAutoWidth ||
1445 SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eWidthType ||
1447}
1448
1449void SwCSS1Parser::AddClassName( OUString& rFormatName, std::u16string_view rClass )
1450{
1451 OSL_ENSURE( !rClass.empty(), "Style class without length?" );
1452
1453 rFormatName += OUString::Concat(".") + rClass;
1454}
1455
1457 SfxItemSet& rItemSet,
1458 const OUString *pName )
1459{
1460 // the number of lines matches somehow a percentage value
1461 // for the height (what happens with absolute heights???)
1462 sal_uInt8 nLines = rDrop.GetLines();
1463 if( const SvxFontHeightItem* pFontHeightItem = rItemSet.GetItemIfSet( RES_CHRATR_FONTSIZE, false ) )
1464 {
1465 sal_uInt16 nProp = pFontHeightItem->GetProp();
1466 nLines = static_cast<sal_uInt8>((nProp + 50) / 100);
1467 if( nLines < 1 )
1468 nLines = 1;
1469 else if( nLines > MAX_DROPCAP_LINES )
1470 nLines = MAX_DROPCAP_LINES;
1471
1472 // Only when nLines>1, then the attribute also is set. Then
1473 // we don't need the font height in the character style.
1474 if( nLines > 1 )
1475 {
1476 rItemSet.ClearItem( RES_CHRATR_FONTSIZE );
1479 }
1480 }
1481
1482 // In case of hard attribution (pName==0) we can stop, if the Initial is
1483 // only one line.
1484 if( nLines<=1 )
1485 return;
1486
1487 rDrop.GetLines() = nLines;
1488
1489 // a right border becomes the spacing to text!
1490 if (const SvxRightMarginItem *const pRightMargin = rItemSet.GetItemIfSet(RES_MARGIN_RIGHT, false))
1491 {
1492 rDrop.GetDistance() = static_cast<sal_uInt16>(pRightMargin->GetRight());
1493 rItemSet.ClearItem(RES_MARGIN_RIGHT);
1494 }
1497
1498 // for every other attribute create a character style
1499 if( !rItemSet.Count() )
1500 return;
1501
1502 SwCharFormat *pCFormat = nullptr;
1503 OUString aName;
1504 if( pName )
1505 {
1506 aName = *pName + ".FL"; // first letter
1507 pCFormat = m_pDoc->FindCharFormatByName( aName );
1508 }
1509 else
1510 {
1511 do
1512 {
1513 aName = "first-letter " + OUString::number( static_cast<sal_Int32>(++m_nDropCapCnt) );
1514 }
1516 }
1517
1518 if( !pCFormat )
1519 {
1521 pCFormat->SetAuto(false);
1522 }
1523 SetCharFormatAttrs( pCFormat, rItemSet );
1524
1525 // The character style needs only be set in the attribute, when
1526 // the attribute also is set.
1527 if( nLines > 1 )
1528 rDrop.SetCharFormat( pCFormat );
1529}
1530
1531// specific CSS1 of SwHTMLParsers
1532
1534{
1535 // find the table entry of the item ...
1536 HTMLAttr **ppAttr = nullptr;
1537 switch( nWhich )
1538 {
1539 case RES_CHRATR_BLINK:
1540 ppAttr = &m_xAttrTab->pBlink;
1541 break;
1542 case RES_CHRATR_CASEMAP:
1543 ppAttr = &m_xAttrTab->pCaseMap;
1544 break;
1545 case RES_CHRATR_COLOR:
1546 ppAttr = &m_xAttrTab->pFontColor;
1547 break;
1549 ppAttr = &m_xAttrTab->pStrike;
1550 break;
1552 ppAttr = &m_xAttrTab->pEscapement;
1553 break;
1554 case RES_CHRATR_FONT:
1555 ppAttr = &m_xAttrTab->pFont;
1556 break;
1558 ppAttr = &m_xAttrTab->pFontCJK;
1559 break;
1561 ppAttr = &m_xAttrTab->pFontCTL;
1562 break;
1564 ppAttr = &m_xAttrTab->pFontHeight;
1565 break;
1567 ppAttr = &m_xAttrTab->pFontHeightCJK;
1568 break;
1570 ppAttr = &m_xAttrTab->pFontHeightCTL;
1571 break;
1572 case RES_CHRATR_KERNING:
1573 ppAttr = &m_xAttrTab->pKerning;
1574 break;
1575 case RES_CHRATR_POSTURE:
1576 ppAttr = &m_xAttrTab->pItalic;
1577 break;
1579 ppAttr = &m_xAttrTab->pItalicCJK;
1580 break;
1582 ppAttr = &m_xAttrTab->pItalicCTL;
1583 break;
1585 ppAttr = &m_xAttrTab->pUnderline;
1586 break;
1587 case RES_CHRATR_WEIGHT:
1588 ppAttr = &m_xAttrTab->pBold;
1589 break;
1591 ppAttr = &m_xAttrTab->pBoldCJK;
1592 break;
1594 ppAttr = &m_xAttrTab->pBoldCTL;
1595 break;
1597 ppAttr = &m_xAttrTab->pCharBrush;
1598 break;
1599 case RES_CHRATR_BOX:
1600 ppAttr = &m_xAttrTab->pCharBox;
1601 break;
1602
1604 ppAttr = &m_xAttrTab->pLineSpacing;
1605 break;
1606 case RES_PARATR_ADJUST:
1607 ppAttr = &m_xAttrTab->pAdjust;
1608 break;
1609
1611 ppAttr = &m_xAttrTab->pFirstLineIndent;
1612 break;
1614 ppAttr = &m_xAttrTab->pTextLeftMargin;
1615 break;
1616 case RES_MARGIN_RIGHT:
1617 ppAttr = &m_xAttrTab->pRightMargin;
1618 break;
1619 case RES_UL_SPACE:
1620 ppAttr = &m_xAttrTab->pULSpace;
1621 break;
1622 case RES_BOX:
1623 ppAttr = &m_xAttrTab->pBox;
1624 break;
1625 case RES_BACKGROUND:
1626 ppAttr = &m_xAttrTab->pBrush;
1627 break;
1628 case RES_BREAK:
1629 ppAttr = &m_xAttrTab->pBreak;
1630 break;
1631 case RES_PAGEDESC:
1632 ppAttr = &m_xAttrTab->pPageDesc;
1633 break;
1634 case RES_PARATR_SPLIT:
1635 ppAttr = &m_xAttrTab->pSplit;
1636 break;
1637 case RES_PARATR_WIDOWS:
1638 ppAttr = &m_xAttrTab->pWidows;
1639 break;
1640 case RES_PARATR_ORPHANS:
1641 ppAttr = &m_xAttrTab->pOrphans;
1642 break;
1643 case RES_KEEP:
1644 ppAttr = &m_xAttrTab->pKeep;
1645 break;
1646
1648 ppAttr = &m_xAttrTab->pLanguage;
1649 break;
1651 ppAttr = &m_xAttrTab->pLanguageCJK;
1652 break;
1654 ppAttr = &m_xAttrTab->pLanguageCTL;
1655 break;
1656
1657 case RES_FRAMEDIR:
1658 ppAttr = &m_xAttrTab->pDirection;
1659 break;
1660 }
1661
1662 return ppAttr;
1663}
1664
1666{
1667 OUString sType;
1668
1669 const HTMLOptions& rOptions2 = GetOptions();
1670 for (size_t i = rOptions2.size(); i; )
1671 {
1672 const HTMLOption& rOption = rOptions2[--i];
1673 if( HtmlOptionId::TYPE == rOption.GetToken() )
1674 sType = rOption.GetString();
1675 }
1676
1677 m_bIgnoreRawData = sType.getLength() &&
1679}
1680
1682{
1683 m_bIgnoreRawData = false;
1684
1685 if( !m_aStyleSource.isEmpty() )
1686 {
1687 m_pCSS1Parser->ParseStyleSheet( m_aStyleSource );
1688 m_aStyleSource.clear();
1689 }
1690}
1691
1692bool SwHTMLParser::FileDownload( const OUString& rURL,
1693 OUString& rStr )
1694{
1695 // depose view (because of reschedule)
1696 SwViewShell *pOldVSh = CallEndAction();
1697
1698 SfxMedium aDLMedium( rURL, StreamMode::READ | StreamMode::SHARE_DENYWRITE );
1699
1700 SvStream* pStream = aDLMedium.GetInStream();
1701 if( pStream )
1702 {
1703 SvMemoryStream aStream;
1704 aStream.WriteStream( *pStream );
1705
1706 rStr = OUString(static_cast<const char *>(aStream.GetData()), aStream.TellEnd(),
1707 GetSrcEncoding());
1708 }
1709
1710 // was aborted?
1711 if( ( m_xDoc->GetDocShell() && m_xDoc->GetDocShell()->IsAbortingImport() )
1712 || 1 == m_xDoc->getReferenceCount() )
1713 {
1714 // was the import aborted from SFX?
1715 eState = SvParserState::Error;
1716 pStream = nullptr;
1717 }
1718
1719 // recreate View
1720 SwViewShell *const pVSh = CallStartAction( pOldVSh );
1721 OSL_ENSURE( pOldVSh == pVSh, "FileDownload: SwViewShell changed on us" );
1722
1723 return pStream!=nullptr;
1724}
1725
1727{
1728 bool bFinishDownload = false;
1729 if( !m_vPendingStack.empty() )
1730 {
1731 OSL_ENSURE( ShouldFinishFileDownload(),
1732 "Pending-Stack without File-Download?" );
1733
1734 m_vPendingStack.pop_back();
1735 assert( m_vPendingStack.empty() && "Where does the Pending-Stack come from?" );
1736
1737 bFinishDownload = true;
1738 }
1739 else
1740 {
1741 OUString sRel, sHRef, sType;
1742
1743 const HTMLOptions& rOptions2 = GetOptions();
1744 for (size_t i = rOptions2.size(); i; )
1745 {
1746 const HTMLOption& rOption = rOptions2[--i];
1747 switch( rOption.GetToken() )
1748 {
1749 case HtmlOptionId::REL:
1750 sRel = rOption.GetString();
1751 break;
1752 case HtmlOptionId::HREF:
1754 break;
1755 case HtmlOptionId::TYPE:
1756 sType = rOption.GetString();
1757 break;
1758 default: break;
1759 }
1760 }
1761
1762 if( !sHRef.isEmpty() && sRel.equalsIgnoreAsciiCase( "STYLESHEET" ) &&
1763 ( sType.isEmpty() ||
1765 {
1766 if( GetMedium() )
1767 {
1768 // start download of style source
1769 StartFileDownload(sHRef);
1770 if( IsParserWorking() )
1771 {
1772 // The style was loaded synchronously and we can call it directly.
1773 bFinishDownload = true;
1774 }
1775 else
1776 {
1777 // The style was load asynchronously and is only available
1778 // on the next continue call. Therefore we must create a
1779 // Pending stack, so that we will return to here.
1780 m_vPendingStack.emplace_back( HtmlTokenId::LINK );
1781 }
1782 }
1783 else
1784 {
1785 // load file synchronous
1786 OUString sSource;
1787 if( FileDownload( sHRef, sSource ) )
1788 m_pCSS1Parser->ParseStyleSheet( sSource );
1789 }
1790 }
1791 }
1792
1793 if( bFinishDownload )
1794 {
1795 OUString sSource;
1796 if( FinishFileDownload( sSource ) && !sSource.isEmpty() )
1797 m_pCSS1Parser->ParseStyleSheet( sSource );
1798 }
1799}
1800
1801bool SwCSS1Parser::ParseStyleSheet( const OUString& rIn )
1802{
1803 if( !SvxCSS1Parser::ParseStyleSheet( rIn ) )
1804 return false;
1805
1806 SwPageDesc *pMasterPageDesc =
1808
1809 SvxCSS1MapEntry* pPageEntry = GetPage(OUString(), false);
1810 if( pPageEntry )
1811 {
1812 // @page (affects all already existing pages)
1813
1814 SetPageDescAttrs( pMasterPageDesc, pPageEntry->GetItemSet(),
1815 pPageEntry->GetPropertyInfo() );
1816
1817 // For all other already existing page styles the attributes
1818 // must also be set
1819
1821 pPageEntry->GetPropertyInfo() );
1823 pPageEntry->GetPropertyInfo() );
1825 pPageEntry->GetPropertyInfo() );
1826
1827 }
1828
1829 pPageEntry = GetPage( "first", true );
1830 if( pPageEntry )
1831 {
1832 SetPageDescAttrs( GetFirstPageDesc(true), pPageEntry->GetItemSet(),
1833 pPageEntry->GetPropertyInfo() );
1834 m_bSetFirstPageDesc = true;
1835 }
1836
1837 pPageEntry = GetPage( "right", true );
1838 if( pPageEntry )
1839 {
1840 SetPageDescAttrs( GetRightPageDesc(true), pPageEntry->GetItemSet(),
1841 pPageEntry->GetPropertyInfo() );
1842 m_bSetRightPageDesc = true;
1843 }
1844
1845 pPageEntry = GetPage( "left", true );
1846 if( pPageEntry )
1847 SetPageDescAttrs( GetLeftPageDesc(true), pPageEntry->GetItemSet(),
1848 pPageEntry->GetPropertyInfo() );
1849
1850 return true;
1851}
1852
1853bool SwHTMLParser::ParseStyleOptions( const OUString &rStyle,
1854 const OUString &rId,
1855 const OUString &rClass,
1856 SfxItemSet &rItemSet,
1857 SvxCSS1PropertyInfo &rPropInfo,
1858 const OUString *pLang,
1859 const OUString *pDir )
1860{
1861 bool bRet = false;
1862
1863 if( !rClass.isEmpty() )
1864 {
1865 OUString aClass( rClass );
1867 const SvxCSS1MapEntry *pClass = m_pCSS1Parser->GetClass( aClass );
1868 if( pClass )
1869 {
1871 pClass->GetPropertyInfo(),
1872 rItemSet, rPropInfo, false );
1873 bRet = true;
1874 }
1875 }
1876
1877 if( !rId.isEmpty() )
1878 {
1879 const SvxCSS1MapEntry *pId = m_pCSS1Parser->GetId( rId );
1880 if( pId )
1882 pId->GetPropertyInfo(),
1883 rItemSet, rPropInfo, !rClass.isEmpty() );
1884 rPropInfo.m_aId = rId;
1885 bRet = true;
1886 }
1887
1888 if( !rStyle.isEmpty() )
1889 {
1890 m_pCSS1Parser->ParseStyleOption( rStyle, rItemSet, rPropInfo );
1891 bRet = true;
1892 }
1893
1894 if( bRet )
1895 rPropInfo.SetBoxItem( rItemSet, MIN_BORDER_DIST );
1896
1897 if( pLang && !pLang->isEmpty() )
1898 {
1900 if( LANGUAGE_DONTKNOW != eLang )
1901 {
1902 SvxLanguageItem aLang( eLang, RES_CHRATR_LANGUAGE );
1903 rItemSet.Put( aLang );
1904 aLang.SetWhich( RES_CHRATR_CJK_LANGUAGE );
1905 rItemSet.Put( aLang );
1906 aLang.SetWhich( RES_CHRATR_CTL_LANGUAGE );
1907 rItemSet.Put( aLang );
1908
1909 bRet = true;
1910 }
1911 }
1912 if( pDir && !pDir->isEmpty() )
1913 {
1914 OUString aValue( *pDir );
1915 SvxFrameDirection eDir = SvxFrameDirection::Environment;
1916 if (aValue.equalsIgnoreAsciiCase("LTR"))
1917 eDir = SvxFrameDirection::Horizontal_LR_TB;
1918 else if (aValue.equalsIgnoreAsciiCase("RTL"))
1919 eDir = SvxFrameDirection::Horizontal_RL_TB;
1920
1921 if( SvxFrameDirection::Environment != eDir )
1922 {
1923 SvxFrameDirectionItem aDir( eDir, RES_FRAMEDIR );
1924 rItemSet.Put( aDir );
1925
1926 bRet = true;
1927 }
1928 }
1929
1930 return bRet;
1931}
1932
1934 SfxItemSet &rFrameItemSet )
1935{
1936 SwFormatAnchor aAnchor;
1937
1938 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
1939 sal_Int16 eVertOri = text::VertOrientation::NONE;
1940 sal_Int16 eHoriRel = text::RelOrientation::FRAME;
1941 sal_Int16 eVertRel = text::RelOrientation::FRAME;
1942 SwTwips nHoriPos = 0, nVertPos = 0;
1943 css::text::WrapTextMode eSurround = css::text::WrapTextMode_THROUGH;
1944 if( SVX_CSS1_POS_ABSOLUTE == rPropInfo.m_ePosition )
1945 {
1946 if( SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType &&
1947 SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eTopType )
1948 {
1949 // Absolute positioned objects are page-bound, when they
1950 // aren't in a frame and otherwise frame-bound.
1951 const SwStartNode *pFlySttNd =
1953 if( pFlySttNd )
1954 {
1955 aAnchor.SetType( RndStdIds::FLY_AT_FLY );
1956 SwPosition aPos( *pFlySttNd );
1957 aAnchor.SetAnchor( &aPos );
1958 }
1959 else
1960 {
1961 aAnchor.SetType( RndStdIds::FLY_AT_PAGE );
1962 aAnchor.SetPageNum( 1 );
1963 }
1964 nHoriPos = rPropInfo.m_nLeft;
1965 nVertPos = rPropInfo.m_nTop;
1966 }
1967 else
1968 {
1969 aAnchor.SetType( RndStdIds::FLY_AT_PARA );
1970 aAnchor.SetAnchor( m_pPam->GetPoint() );
1971 eVertOri = text::VertOrientation::TOP;
1972 eVertRel = text::RelOrientation::CHAR;
1973 if( SVX_CSS1_LTYPE_TWIP == rPropInfo.m_eLeftType )
1974 {
1975 eHoriOri = text::HoriOrientation::NONE;
1976 eHoriRel = text::RelOrientation::PAGE_FRAME;
1977 nHoriPos = rPropInfo.m_nLeft;
1978 }
1979 else
1980 {
1981 eHoriOri = text::HoriOrientation::LEFT;
1982 eHoriRel = text::RelOrientation::FRAME; // to be changed later
1983 }
1984 }
1985 }
1986 else
1987 {
1988 // Flowing object are inserted as paragraph-bound, when the paragraph is
1989 // still empty and otherwise auto-bound.
1990 // Auto-bound frames for the time being inserted at the previous position
1991 // and later moved.
1992 const sal_Int32 nContent = m_pPam->GetPoint()->GetContentIndex();
1993 if( nContent )
1994 {
1995 aAnchor.SetType( RndStdIds::FLY_AT_CHAR );
1997 eVertOri = text::VertOrientation::CHAR_BOTTOM;
1998 eVertRel = text::RelOrientation::CHAR;
1999 }
2000 else
2001 {
2002 aAnchor.SetType( RndStdIds::FLY_AT_PARA );
2003 eVertOri = text::VertOrientation::TOP;
2004 eVertRel = text::RelOrientation::PRINT_AREA;
2005 }
2006
2007 aAnchor.SetAnchor( m_pPam->GetPoint() );
2008
2009 if( nContent )
2011
2012 sal_uInt16 nLeftSpace = 0, nRightSpace = 0;
2013 short nIndent = 0;
2014 GetMarginsFromContextWithNumberBullet( nLeftSpace, nRightSpace, nIndent );
2015
2016 if( SvxAdjust::Right==rPropInfo.m_eFloat )
2017 {
2018 eHoriOri = text::HoriOrientation::RIGHT;
2019 eHoriRel = nRightSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
2020 eSurround = css::text::WrapTextMode_LEFT;
2021 }
2022 else
2023 {
2024 eHoriOri = text::HoriOrientation::LEFT;
2025 eHoriRel = nLeftSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
2026 eSurround = css::text::WrapTextMode_RIGHT;
2027 }
2028 }
2029 rFrameItemSet.Put( aAnchor );
2030
2031 // positioned absolutely with wrap
2032 rFrameItemSet.Put( SwFormatHoriOrient( nHoriPos, eHoriOri, eHoriRel ) );
2033 rFrameItemSet.Put( SwFormatVertOrient( nVertPos, eVertOri, eVertRel ) );
2034 rFrameItemSet.Put( SwFormatSurround( eSurround ) );
2035}
2036
2038 SfxItemSet &rFrameItemSet,
2039 SwTwips nDfltWidth, sal_uInt8 nDfltPrcWidth )
2040{
2041 SwTwips nWidth = nDfltWidth, nHeight = MINFLY;
2042 sal_uInt8 nPercentWidth = nDfltPrcWidth, nPercentHeight = 0;
2043 switch( rPropInfo.m_eWidthType )
2044 {
2046 nPercentWidth = rPropInfo.m_nWidth > 0 ? static_cast<sal_uInt8>(rPropInfo.m_nWidth) : 1;
2047 nWidth = MINFLY;
2048 break;
2050 nWidth = std::max<tools::Long>(rPropInfo.m_nWidth, MINFLY);
2051 nPercentWidth = 0;
2052 break;
2053 default:
2054 ;
2055 }
2056 switch( rPropInfo.m_eHeightType )
2057 {
2059 nPercentHeight = rPropInfo.m_nHeight > 0 ? static_cast<sal_uInt8>(rPropInfo.m_nHeight) : 1;
2060 break;
2062 // Netscape and MS-IE interpreting the height incorrectly as minimum height,
2063 // therefore we are doing the same.
2064 nHeight = std::max<tools::Long>(rPropInfo.m_nHeight, MINFLY);
2065 break;
2066 default:
2067 ;
2068 }
2069
2070 SwFormatFrameSize aFrameSize( SwFrameSize::Minimum, nWidth, nHeight );
2071 aFrameSize.SetWidthPercent( nPercentWidth );
2072 aFrameSize.SetHeightPercent( nPercentHeight );
2073 rFrameItemSet.Put( aFrameSize );
2074}
2075
2077 HtmlFrameFormatFlags nFlags,
2078 SfxItemSet &rFrameItemSet )
2079{
2080 const SvxBoxItem *pBoxItem;
2081 if( (nFlags & HtmlFrameFormatFlags::Box) &&
2082 (pBoxItem = rItemSet.GetItemIfSet( RES_BOX )) )
2083 {
2084 if( nFlags & HtmlFrameFormatFlags::Padding )
2085 {
2086 SvxBoxItem aBoxItem( *pBoxItem );
2087 // reset all 4 sides to 0
2088 aBoxItem.SetAllDistances(0);
2089 rFrameItemSet.Put( aBoxItem );
2090 }
2091 else
2092 {
2093 rFrameItemSet.Put( *pBoxItem );
2094 }
2095 rItemSet.ClearItem( RES_BOX );
2096 }
2097
2098 const SvxBrushItem* pBrushItem;
2099 if( (nFlags & HtmlFrameFormatFlags::Background) &&
2100 (pBrushItem = rItemSet.GetItemIfSet( RES_BACKGROUND )) )
2101 {
2102 rFrameItemSet.Put( *pBrushItem );
2103 rItemSet.ClearItem( RES_BACKGROUND );
2104 }
2105
2106 const SvxFrameDirectionItem* pFrameDirectionItem;
2107 if( (nFlags & HtmlFrameFormatFlags::Direction) &&
2108 (pFrameDirectionItem = rItemSet.GetItemIfSet( RES_FRAMEDIR )) )
2109 {
2110 rFrameItemSet.Put( *pFrameDirectionItem );
2111 rItemSet.ClearItem( RES_FRAMEDIR );
2112 }
2113}
2114
2115std::unique_ptr<HTMLAttrContext> SwHTMLParser::PopContext( HtmlTokenId nToken )
2116{
2117 std::unique_ptr<HTMLAttrContext> xCntxt;
2118
2119 HTMLAttrContexts::size_type nPos = m_aContexts.size();
2120 if( nPos <= m_nContextStMin )
2121 return nullptr;
2122
2123 bool bFound = HtmlTokenId::NONE == nToken;
2124 if( nToken != HtmlTokenId::NONE )
2125 {
2126 // search for stack entry of token ...
2127 while( nPos > m_nContextStMin )
2128 {
2129 HtmlTokenId nCntxtToken = m_aContexts[--nPos]->GetToken();
2130 if( nCntxtToken == nToken )
2131 {
2132 bFound = true;
2133 break;
2134 }
2135 else if( nCntxtToken == HtmlTokenId::NONE ) // zero as token doesn't occur
2136 {
2137 break;
2138 }
2139 }
2140 }
2141 else
2142 {
2143 nPos--;
2144 }
2145
2146 if( bFound )
2147 {
2148 xCntxt = std::move(m_aContexts[nPos]);
2149 m_aContexts.erase( m_aContexts.begin() + nPos );
2150 }
2151
2152 return xCntxt;
2153}
2154
2156 sal_uInt16& nRight,
2157 short& nIndent,
2158 bool bIgnoreTopContext ) const
2159{
2160 HTMLAttrContexts::size_type nPos = m_aContexts.size();
2161 if( bIgnoreTopContext )
2162 {
2163 if( !nPos )
2164 return;
2165 else
2166 nPos--;
2167 }
2168
2169 while( nPos > m_nContextStAttrMin )
2170 {
2171 const HTMLAttrContext *pCntxt = m_aContexts[--nPos].get();
2172 if( pCntxt->IsLRSpaceChanged() )
2173 {
2174 pCntxt->GetMargins( nLeft, nRight, nIndent );
2175 return;
2176 }
2177 }
2178}
2179
2181 sal_uInt16& nRight,
2182 short& nIndent ) const
2183{
2184 GetMarginsFromContext( nLeft, nRight, nIndent );
2185 const SwHTMLNumRuleInfo& rInfo = const_cast<SwHTMLParser*>(this)->GetNumInfo();
2186 if( rInfo.GetDepth() )
2187 {
2188 sal_uInt8 nLevel = static_cast<sal_uInt8>( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
2189 : MAXLEVEL) - 1 );
2190 const SwNumFormat& rNumFormat = rInfo.GetNumRule()->Get(nLevel);
2191 nLeft = nLeft + rNumFormat.GetAbsLSpace(); //TODO: overflow
2192 nIndent = rNumFormat.GetFirstLineOffset(); //TODO: overflow
2193 }
2194}
2195
2197 sal_uInt16& nLower ) const
2198{
2199 sal_uInt16 nDefaultColl = 0;
2200 OUString aDefaultClass;
2201
2202 HTMLAttrContexts::size_type nPos = m_aContexts.size();
2203 while( nPos > m_nContextStAttrMin )
2204 {
2205 const HTMLAttrContext *pCntxt = m_aContexts[--nPos].get();
2206 if( pCntxt->IsULSpaceChanged() )
2207 {
2208 pCntxt->GetULSpace( nUpper, nLower );
2209 return;
2210 }
2211 else if (!nDefaultColl)
2212 {
2213 nDefaultColl = pCntxt->GetDefaultTextFormatColl();
2214 if (nDefaultColl)
2215 aDefaultClass = pCntxt->GetClass();
2216 }
2217 }
2218
2219 if (!nDefaultColl)
2220 nDefaultColl = RES_POOLCOLL_TEXT;
2221
2222 const SwTextFormatColl *pColl =
2223 m_pCSS1Parser->GetTextFormatColl(nDefaultColl, aDefaultClass);
2224 const SvxULSpaceItem& rULSpace = pColl->GetULSpace();
2225 nUpper = rULSpace.GetUpper();
2226 nLower = rULSpace.GetLower();
2227}
2228
2230{
2231 HTMLAttrs &rAttrs = pContext->GetAttrs();
2232 for( auto pAttr : rAttrs )
2233 {
2234 if( RES_PARATR_DROP==pAttr->GetItem().Which() )
2235 {
2236 // Set the number of characters for DropCaps. If it's zero at the
2237 // end, the attribute is set to invalid and then isn't set from SetAttr.
2238 sal_Int32 nChars = m_pPam->GetPoint()->GetContentIndex();
2239 if( nChars < 1 )
2240 pAttr->Invalidate();
2241 else if( nChars > MAX_DROPCAP_CHARS )
2242 nChars = MAX_DROPCAP_CHARS;
2243 static_cast<SwFormatDrop&>(pAttr->GetItem()).GetChars() = static_cast<sal_uInt8>(nChars);
2244 }
2245
2246 EndAttr( pAttr );
2247 }
2248}
2249
2251{
2252 SfxItemIter aIter( rItemSet );
2253
2254 for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
2255 {
2256 // search for the table entry of the item...
2257 sal_uInt16 nWhich = pItem->Which();
2258 HTMLAttr **ppAttr = GetAttrTabEntry( nWhich );
2259
2260 if( ppAttr )
2261 {
2262 NewAttr(m_xAttrTab, ppAttr, *pItem);
2263 if( RES_PARATR_BEGIN > nWhich )
2264 (*ppAttr)->SetLikePara();
2265 m_aParaAttrs.push_back( *ppAttr );
2266 bool bSuccess = EndAttr( *ppAttr, false );
2267 if (!bSuccess)
2268 m_aParaAttrs.pop_back();
2269 }
2270 }
2271}
2272
2273static void lcl_swcss1_setEncoding( SwFormat& rFormat, rtl_TextEncoding eEnc )
2274{
2275 if( RTL_TEXTENCODING_DONTKNOW == eEnc )
2276 return;
2277
2278 const SfxItemSet& rItemSet = rFormat.GetAttrSet();
2279 static const TypedWhichId<SvxFontItem> aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
2281 for (auto const & i : aWhichIds)
2282 {
2283 const SvxFontItem *pFontItem = rItemSet.GetItemIfSet(i, false);
2284 if (!pFontItem)
2285 continue;
2286 if (RTL_TEXTENCODING_SYMBOL == pFontItem->GetCharSet())
2287 continue;
2288 if (eEnc == pFontItem->GetCharSet())
2289 continue;
2290 SvxFontItem aFont(pFontItem->GetFamily(), pFontItem->GetFamilyName(),
2291 pFontItem->GetStyleName(), pFontItem->GetPitch(),
2292 eEnc, i);
2293 rFormat.SetFormatAttr(aFont);
2294 }
2295}
2296
2297void SwCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
2298{
2299 if( eEnc == GetDfltEncoding() )
2300 return;
2301
2302 if( m_bIsNewDoc )
2303 {
2304 // Set new encoding as pool default
2305 static const sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,
2307 for(sal_uInt16 i : aWhichIds)
2308 {
2309 const SvxFontItem& rDfltFont =
2310 static_cast<const SvxFontItem&>(m_pDoc->GetDefault( i));
2311 SvxFontItem aFont( rDfltFont.GetFamily(),
2312 rDfltFont.GetFamilyName(),
2313 rDfltFont.GetStyleName(),
2314 rDfltFont.GetPitch(),
2315 eEnc, i );
2316 m_pDoc->SetDefault( aFont );
2317 }
2318
2319 // Change all paragraph styles that do specify a font.
2320 for( auto pTextFormatColl : *m_pDoc->GetTextFormatColls() )
2321 lcl_swcss1_setEncoding( *pTextFormatColl, eEnc );
2322
2323 // Change all character styles that do specify a font.
2324 for( auto pCharFormat : *m_pDoc->GetCharFormats() )
2325 lcl_swcss1_setEncoding( *pCharFormat, eEnc );
2326 }
2327
2329}
2330
2331/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OptionalString sType
const char * pName
GPOS_NONE
A simple selector.
Definition: parcss1.hxx:93
CSS1SelectorType GetType() const
Definition: parcss1.hxx:105
const OUString & GetString() const
Definition: parcss1.hxx:106
const CSS1Selector * GetNext() const
Definition: parcss1.hxx:109
const HTMLAttrs & GetAttrs() const
Definition: swhtml.hxx:272
sal_uInt16 GetDefaultTextFormatColl() const
Definition: swhtml.hxx:257
void GetULSpace(sal_uInt16 &rUpper, sal_uInt16 &rLower) const
Definition: swhtml.hxx:1010
bool IsULSpaceChanged() const
Definition: swhtml.hxx:268
bool IsLRSpaceChanged() const
Definition: swhtml.hxx:263
const OUString & GetClass() const
Definition: swhtml.hxx:259
void GetMargins(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent) const
Definition: swhtml.hxx:991
HtmlOptionId GetToken() const
const OUString & GetString() const
virtual SwPageDesc * GetPageDescFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return required automatic page style.
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
static LanguageType convertToLanguageTypeWithFallback(const OUString &rBcp47)
void StartFileDownload(const OUString &rURL)
SfxMedium * GetMedium()
bool ShouldFinishFileDownload() const
bool FinishFileDownload(OUString &rStr)
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 Count() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SvStream * GetInStream()
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const void * GetData()
virtual sal_uInt64 TellEnd() override
SvStream & WriteStream(SvStream &rStream)
void SetAllDistances(sal_Int16 nNew)
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
const SvxCSS1PropertyInfo & GetPropertyInfo() const
Definition: svxcss1.hxx:178
const SfxItemSet & GetItemSet() const
Definition: svxcss1.hxx:175
void InsertPage(const OUString &rPage, bool bPseudo, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:798
void InsertId(const OUString &rId, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:772
SvxCSS1MapEntry * GetTag(const OUString &rTag)
Definition: svxcss1.cxx:826
virtual void SetDfltEncoding(rtl_TextEncoding eEnc)
Definition: svxcss1.cxx:986
rtl_TextEncoding GetDfltEncoding() const
Definition: svxcss1.hxx:305
void InsertClass(const OUString &rClass, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:785
static void MergeStyles(const SfxItemSet &rSrcSet, const SvxCSS1PropertyInfo &rSrcInfo, SfxItemSet &rTargetSet, SvxCSS1PropertyInfo &rTargetInfo, bool bSmart)
Definition: svxcss1.cxx:939
const SvxCSS1MapEntry * GetClass(const OUString &rClass) const
Definition: svxcss1.cxx:792
SvxCSS1MapEntry * GetPage(const OUString &rPage, bool bPseudo)
Definition: svxcss1.cxx:809
void ParseStyleSheet()
Definition: parcss1.cxx:691
void InsertTag(const OUString &rTag, const SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rProp)
Definition: svxcss1.cxx:819
tools::Long m_nHeight
Definition: svxcss1.hxx:134
SvxCSS1PageBreak m_ePageBreakBefore
Definition: svxcss1.hxx:144
tools::Long m_nTop
Definition: svxcss1.hxx:133
void SetBoxItem(SfxItemSet &rItemSet, sal_uInt16 nMinBorderDist, const SvxBoxItem *pDflt=nullptr)
Definition: svxcss1.cxx:590
SvxCSS1PageBreak m_ePageBreakAfter
Definition: svxcss1.hxx:145
SvxCSS1SizeType m_eSizeType
Definition: svxcss1.hxx:142
SvxCSS1LengthType m_eHeightType
Definition: svxcss1.hxx:138
SvxCSS1Position m_ePosition
Definition: svxcss1.hxx:121
SvxCSS1LengthType m_eWidthType
Definition: svxcss1.hxx:138
tools::Long m_nWidth
Definition: svxcss1.hxx:134
tools::Long m_nLeft
Definition: svxcss1.hxx:133
SvxCSS1LengthType m_eTopType
Definition: svxcss1.hxx:137
SvxAdjust m_eFloat
Definition: svxcss1.hxx:119
SvxCSS1LengthType m_eLeftType
Definition: svxcss1.hxx:137
sal_uInt16 GetProp() const
FontFamily GetFamily() const
FontPitch GetPitch() const
const OUString & GetStyleName() const
rtl_TextEncoding GetCharSet() const
const OUString & GetFamilyName() const
const FontList * GetFontList() const
sal_Int32 GetFirstLineOffset() const
sal_Int32 GetAbsLSpace() const
tools::Long GetHeight() const
tools::Long GetWidth() const
void SetHeight(tools::Long n)
void SetWidth(tools::Long n)
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
sal_uInt16 GetUpper() const
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
sal_uInt16 GetLower() const
virtual sal_uInt32 GetFontHeight(sal_uInt16 nSize) const override
Definition: htmlcss1.cxx:1098
bool m_bSetFirstPageDesc
Definition: swcss1.hxx:63
const SwPageDesc * GetPageDesc(sal_uInt16 nPoolId, bool bCreate)
Definition: htmlcss1.cxx:1330
SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1198
bool SetFormatBreak(SfxItemSet &rItemSet, const SvxCSS1PropertyInfo &rPropInfo)
Definition: htmlcss1.cxx:124
SwTextFormatColl * GetTextFormatColl(sal_uInt16 nTextColl, const OUString &rClass)
Definition: htmlcss1.cxx:1233
bool m_bLinkCharFormatsSet
Definition: swcss1.hxx:69
sal_uInt16 m_nDropCapCnt
Definition: swcss1.hxx:53
const SwPageDesc * GetRightPageDesc(bool bCreate=false)
Definition: swcss1.hxx:173
bool m_bSetRightPageDesc
Definition: swcss1.hxx:64
virtual void SetDfltEncoding(rtl_TextEncoding eEnc) override
Definition: htmlcss1.cxx:2297
sal_uLong m_aFontHeights[7]
Definition: swcss1.hxx:51
SwPageDesc * GetMasterPageDesc()
Definition: htmlcss1.cxx:1314
void ChgPageDesc(const SwPageDesc *pPageDesc, const SwPageDesc &rNewPageDesc)
Definition: htmlcss1.cxx:81
SwCharFormat * GetChrFormat(HtmlTokenId nToken, const OUString &rClass) const
Definition: htmlcss1.cxx:1118
bool m_bBodyVLinkSet
Definition: swcss1.hxx:61
SwDoc * m_pDoc
Definition: swcss1.hxx:48
const SwPageDesc * GetFirstPageDesc(bool bCreate=false)
Definition: swcss1.hxx:168
bool m_bBodyBGColorSet
Definition: swcss1.hxx:57
bool m_bBodyLinkSet
Definition: swcss1.hxx:60
SwHTMLParser const & m_rHTMLParser
Definition: swcss1.hxx:49
static Css1ScriptFlags GetScriptFromClass(OUString &rClass, bool bSubClassOnly=true)
Definition: htmlcss1.cxx:553
void FillDropCap(SwFormatDrop &rDrop, SfxItemSet &rItemSet, const OUString *pName=nullptr)
Definition: htmlcss1.cxx:1456
virtual const FontList * GetFontList() const override
Definition: htmlcss1.cxx:1103
SwCSS1Parser(SwDoc *pDoc, SwHTMLParser const &rParser, sal_uInt32 const aFHeight[7], const OUString &rBaseURL, bool bNewDoc)
Definition: htmlcss1.cxx:91
void ParseStyleSheet()
Definition: parcss1.cxx:691
static void AddClassName(OUString &rFormatName, std::u16string_view rClass)
Definition: htmlcss1.cxx:1449
virtual void StyleParsed(const CSS1Selector *pSelector, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo) override
Definition: htmlcss1.cxx:684
const SwPageDesc * GetLeftPageDesc(bool bCreate=false)
Definition: swcss1.hxx:178
void SetLinkCharFormats()
Definition: htmlcss1.cxx:214
std::unique_ptr< SvxBrushItem > makePageDescBackground() const
Definition: htmlcss1.cxx:547
void SetTableTextColl(bool bHeader)
Definition: htmlcss1.cxx:312
bool m_bIsNewDoc
Definition: swcss1.hxx:55
void SetPageDescAttrs(const SvxBrushItem *pBrush, SfxItemSet *pItemSet=nullptr)
Definition: htmlcss1.cxx:357
bool m_bTableTextCollSet
Definition: swcss1.hxx:67
bool m_bBodyTextSet
Definition: swcss1.hxx:59
static bool MayBePositioned(const SvxCSS1PropertyInfo &rPropInfo, bool bAutoWidth=false)
Definition: htmlcss1.cxx:1417
bool m_bTableHeaderTextCollSet
Definition: swcss1.hxx:66
virtual ~SwCSS1Parser() override
Definition: htmlcss1.cxx:119
SwCharFormat * GetCharFormatFromPool(sal_uInt16 nPoolId) const
Definition: htmlcss1.cxx:1215
bool m_bBodyBackgroundSet
Definition: swcss1.hxx:58
Represents the style of a text portion.
Definition: charfmt.hxx:27
size_t size() const
Definition: charformats.hxx:71
SwCharFormatsBase::size_type size_type
Definition: charformats.hxx:63
Definition: doc.hxx:197
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId,...
Definition: docfmt.cxx:1436
bool ContainsPageDesc(const SwPageDesc *pDesc, size_t *pPos) const
Definition: docdesc.cxx:952
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:768
size_t GetPageDescCnt() const
Definition: doc.hxx:895
void SetDefault(const SfxPoolItem &)
Set attribute as new default attribute in current document.
Definition: docfmt.cxx:548
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:786
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:755
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:672
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:793
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:440
void ChgPageDesc(const OUString &rName, const SwPageDesc &)
Definition: docdesc.cxx:978
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:814
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Create the FormatCollections.
Definition: docfmt.cxx:897
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:863
SwDocShell * GetDocShell()
Definition: doc.hxx:1370
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:896
FlyAnchors.
Definition: fmtanchr.hxx:37
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:71
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1593
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:68
If SwFormatDrop is a Client, it is the CharFormat that describes the font for the DropCaps.
Definition: paratr.hxx:72
sal_uInt8 GetLines() const
Definition: paratr.hxx:110
sal_uInt8 GetChars() const
Definition: paratr.hxx:113
void SetCharFormat(SwCharFormat *pNew)
Definition: paratr.cxx:64
sal_uInt16 GetDistance() const
Definition: paratr.hxx:119
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
void SetHeightPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:93
Defines the horizontal position of a fly frame.
Definition: fmtornt.hxx:73
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:36
Defines the vertical position of a fly frame.
Definition: fmtornt.hxx:37
Base class for various Writer styles.
Definition: format.hxx:47
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
const OUString & GetName() const
Definition: format.hxx:131
void SetAuto(bool bNew)
Definition: format.hxx:179
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:100
const SwFormatDrop & GetDrop(bool=true) const
Definition: paratr.hxx:239
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:736
Style of a layout element.
Definition: frmfmt.hxx:72
sal_uInt16 GetDepth() const
Definition: htmlnum.hxx:73
SwNumRule * GetNumRule()
Definition: htmlnum.hxx:69
OUString m_aStyleSource
Definition: swhtml.hxx:369
size_t m_nContextStAttrMin
Definition: swhtml.hxx:425
std::unique_ptr< HTMLAttrContext > PopContext(HtmlTokenId nToken=HtmlTokenId::NONE)
Definition: htmlcss1.cxx:2115
void SetAnchorAndAdjustment(sal_Int16 eVertOri, sal_Int16 eHoriOri, const SvxCSS1PropertyInfo &rPropInfo, SfxItemSet &rFrameSet)
Definition: htmlgrin.cxx:151
void NewStyle()
Definition: htmlcss1.cxx:1665
HTMLAttrContexts m_aContexts
Definition: swhtml.hxx:385
std::shared_ptr< HTMLAttrTable > m_xAttrTab
Definition: swhtml.hxx:384
void EndContextAttrs(HTMLAttrContext *pContext)
Definition: htmlcss1.cxx:2229
void EndStyle()
Definition: htmlcss1.cxx:1681
SwViewShell * CallStartAction(SwViewShell *pVSh=nullptr, bool bChkPtr=true)
Definition: swhtml.cxx:2634
HTMLAttrs m_aParaAttrs
Definition: swhtml.hxx:383
HTMLAttr ** GetAttrTabEntry(sal_uInt16 nWhich)
Definition: htmlcss1.cxx:1533
SwPaM * m_pPam
Definition: swhtml.hxx:399
SwHTMLNumRuleInfo & GetNumInfo()
Definition: swhtml.hxx:566
void NewAttr(const std::shared_ptr< HTMLAttrTable > &rAttrTab, HTMLAttr **ppAttr, const SfxPoolItem &rItem)
Definition: swhtml.cxx:3083
rtl::Reference< SwDoc > m_xDoc
Definition: swhtml.hxx:398
bool ParseStyleOptions(const OUString &rStyle, const OUString &rId, const OUString &rClass, SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, const OUString *pLang=nullptr, const OUString *pDir=nullptr)
Definition: htmlcss1.cxx:1853
bool IsReadingHeaderOrFooter() const
Definition: swhtml.hxx:951
void InsertLink()
Definition: htmlcss1.cxx:1726
std::unique_ptr< SwCSS1Parser > m_pCSS1Parser
Definition: swhtml.hxx:394
std::vector< SwPending > m_vPendingStack
Definition: swhtml.hxx:396
void InsertParaAttrs(const SfxItemSet &rItemSet)
Definition: htmlcss1.cxx:2250
void GetMarginsFromContext(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent, bool bIgnoreCurrent=false) const
Definition: htmlcss1.cxx:2155
void GetMarginsFromContextWithNumberBullet(sal_uInt16 &nLeft, sal_uInt16 &nRight, short &nIndent) const
Definition: htmlcss1.cxx:2180
static void SetFrameFormatAttrs(SfxItemSet &rItemSet, HtmlFrameFormatFlags nFlags, SfxItemSet &rFrameItemSet)
Definition: htmlcss1.cxx:2076
bool m_bIgnoreRawData
Definition: swhtml.hxx:451
bool EndAttr(HTMLAttr *pAttr, bool bChkEmpty=true)
Definition: swhtml.cxx:3099
OUString m_sBaseURL
Definition: swhtml.hxx:363
size_t m_nContextStMin
Definition: swhtml.hxx:424
bool FileDownload(const OUString &rURL, OUString &rStr)
Definition: htmlcss1.cxx:1692
void GetULSpaceFromContext(sal_uInt16 &rUpper, sal_uInt16 &rLower) const
Definition: htmlcss1.cxx:2196
static void SetVarSize(SvxCSS1PropertyInfo const &rPropInfo, SfxItemSet &rFlyItemSet, SwTwips nDfltWidth=MINLAY, sal_uInt8 nDefaultPercentWidth=0)
Definition: htmlcss1.cxx:2037
SwViewShell * CallEndAction(bool bChkAction=false, bool bChkPtr=true)
Definition: swhtml.cxx:2663
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:220
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:87
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:657
const SwPosition * GetPoint() const
Definition: pam.hxx:253
void SetFollow(const SwPageDesc *pNew)
Definition: pagedesc.hxx:314
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
bool GetLandscape() const
Definition: pagedesc.hxx:199
void SetLandscape(bool bNew)
Definition: pagedesc.hxx:200
Starts a section of nodes in the document model.
Definition: node.hxx:348
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
virtual bool SetFormatAttr(const SfxPoolItem &rAttr) override
Override to recognize changes on the <SwNumRuleItem> and register/unregister the paragragh style at t...
Definition: fmtcol.cxx:395
std::vector< SwTextFormatColl * >::size_type size_type
Definition: docary.hxx:67
size_t size() const
Definition: docary.hxx:88
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
bool swhtml_css1atr_equalFontItems(const SfxPoolItem &r1, const SfxPoolItem &r2)
Definition: css1atr.cxx:976
constexpr std::string_view sCSS_mimetype
Definition: css1kywd.hxx:27
DocumentType eType
@ Fixed
Frame cannot be moved in Var-direction.
@ Minimum
Value in Var-direction gives minimum (can be exceeded but not be less).
OUString sName
SvxFrameDirection
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(126)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SvxCrossedOutItem > RES_CHRATR_CROSSEDOUT(5)
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(116)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxUnderlineItem > RES_CHRATR_UNDERLINE(14)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxAdjustItem > RES_PARATR_ADJUST(64)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SvxEscapementItem > RES_CHRATR_ESCAPEMENT(6)
constexpr TypedWhichId< SvxBrushItem > RES_CHRATR_BACKGROUND(21)
constexpr TypedWhichId< SvxCaseMapItem > RES_CHRATR_CASEMAP(RES_CHRATR_BEGIN)
constexpr TypedWhichId< SvxLineSpacingItem > RES_PARATR_LINESPACING(RES_PARATR_BEGIN)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr TypedWhichId< SvxOrphansItem > RES_PARATR_ORPHANS(66)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxBlinkItem > RES_CHRATR_BLINK(18)
constexpr TypedWhichId< SvxWidowsItem > RES_PARATR_WIDOWS(67)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
constexpr TypedWhichId< SvxRightMarginItem > RES_MARGIN_RIGHT(93)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxKerningItem > RES_CHRATR_KERNING(9)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SvxFormatSplitItem > RES_PARATR_SPLIT(65)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SvxBoxItem > RES_CHRATR_BOX(40)
constexpr TypedWhichId< SvxColorItem > RES_CHRATR_COLOR(3)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
static void SetTextCollAttrs(SwTextFormatColl *pColl, SfxItemSet &rItemSet, SvxCSS1PropertyInfo const &rPropInfo, SwCSS1Parser *pCSS1Parser)
Definition: htmlcss1.cxx:266
static void lcl_swcss1_setEncoding(SwFormat &rFormat, rtl_TextEncoding eEnc)
Definition: htmlcss1.cxx:2273
static SwPageDesc * FindPageDesc(SwDoc *pDoc, sal_uInt16 nPoolId)
Definition: htmlcss1.cxx:1319
static void SetCharFormatAttrs(SwCharFormat *pCharFormat, SfxItemSet &rItemSet)
Definition: htmlcss1.cxx:180
const sal_uInt16 aItemIds[]
Definition: htmlcss1.cxx:74
#define MAX_DROPCAP_CHARS
Definition: htmlcss1.cxx:69
static CSS1SelectorType GetTokenAndClass(const CSS1Selector *pSelector, OUString &rToken, OUString &rClass, Css1ScriptFlags &rScriptFlags)
Definition: htmlcss1.cxx:606
static void RemoveScriptItems(SfxItemSet &rItemSet, Css1ScriptFlags nScript, const SfxItemSet *pParentItemSet=nullptr)
Definition: htmlcss1.cxx:634
#define MAX_DROPCAP_LINES
Definition: htmlcss1.cxx:68
#define OOO_STRING_SVTOOLS_HTML_parabreak
#define OOO_STRING_SVTOOLS_HTML_shortquote
#define OOO_STRING_SVTOOLS_HTML_abbreviation
#define OOO_STRING_SVTOOLS_HTML_tabledata
#define OOO_STRING_SVTOOLS_HTML_tableheader
#define OOO_STRING_SVTOOLS_HTML_deletedtext
#define OOO_STRING_SVTOOLS_HTML_sdendnote_sym
#define OOO_STRING_SVTOOLS_HTML_anchor
#define OOO_STRING_SVTOOLS_HTML_acronym
#define OOO_STRING_SVTOOLS_HTML_insertedtext
#define OOO_STRING_SVTOOLS_HTML_sdendnote
#define OOO_STRING_SVTOOLS_HTML_person
#define OOO_STRING_SVTOOLS_HTML_author
#define OOO_STRING_SVTOOLS_HTML_sdfootnote_sym
#define OOO_STRING_SVTOOLS_HTML_sdfootnote
#define OOO_STRING_SVTOOLS_HTML_language
SVT_DLLPUBLIC HtmlTokenId GetHTMLToken(std::u16string_view rName)
HtmlTokenId
OUString aName
#define LANGUAGE_DONTKNOW
sal_uInt16 nPos
#define SAL_WARN(area, stream)
#define SAL_N_ELEMENTS(arr)
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
int i
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
bool equalsAscii(std::u16string_view s1, std::string_view s2)
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
CSS1SelectorType
Definition: parcss1.hxx:72
@ CSS1_SELTYPE_ELEM_CLASS
Definition: parcss1.hxx:74
@ CSS1_SELTYPE_CLASS
Definition: parcss1.hxx:75
@ CSS1_SELTYPE_PAGE
Definition: parcss1.hxx:78
@ CSS1_SELTYPE_PSEUDO
Definition: parcss1.hxx:77
@ CSS1_SELTYPE_ELEMENT
Definition: parcss1.hxx:73
@ CSS1_SELTYPE_ID
Definition: parcss1.hxx:76
::std::vector< HTMLOption > HTMLOptions
@ RES_POOLCOLL_HEADLINE5
Heading 5.
Definition: poolfmt.hxx:266
@ RES_POOLCOLL_TEXT
Text body.
Definition: poolfmt.hxx:251
@ RES_POOLCOLL_STANDARD
Standard.
Definition: poolfmt.hxx:250
@ RES_POOLCOLL_HEADLINE6
Heading 6.
Definition: poolfmt.hxx:267
@ RES_POOLCOLL_HTML_BLOCKQUOTE
Definition: poolfmt.hxx:434
@ RES_POOLCOLL_HTML_DD
Definition: poolfmt.hxx:437
@ RES_POOLCOLL_TABLE
Subgroup table.
Definition: poolfmt.hxx:341
@ RES_POOLCOLL_HTML_DT
Definition: poolfmt.hxx:438
@ RES_POOLCOLL_SEND_ADDRESS
Sender.
Definition: poolfmt.hxx:355
@ RES_POOLCOLL_HEADLINE2
Heading 2.
Definition: poolfmt.hxx:263
@ RES_POOLCOLL_HEADLINE4
Heading 4.
Definition: poolfmt.hxx:265
@ RES_POOLCOLL_FOOTNOTE
Footnotes.
Definition: poolfmt.hxx:353
@ RES_POOLCOLL_HTML_PRE
Definition: poolfmt.hxx:435
@ RES_POOLCOLL_HEADLINE1
Heading 1.
Definition: poolfmt.hxx:262
@ RES_POOLCOLL_TABLE_HDLN
Table of Contents - heading.
Definition: poolfmt.hxx:342
@ RES_POOLCOLL_HEADLINE3
Heading 3.
Definition: poolfmt.hxx:264
@ RES_POOLCOLL_ENDNOTE
Endnotes.
Definition: poolfmt.hxx:356
@ RES_POOLPAGE_LEFT
Left page.
Definition: poolfmt.hxx:172
@ RES_POOLPAGE_HTML
HTML.
Definition: poolfmt.hxx:176
@ RES_POOLPAGE_FIRST
First page.
Definition: poolfmt.hxx:171
@ RES_POOLPAGE_RIGHT
Right page.
Definition: poolfmt.hxx:173
@ RES_POOLCHR_HTML_TELETYPE
Definition: poolfmt.hxx:143
@ RES_POOLCHR_INET_VISIT
Internet visited.
Definition: poolfmt.hxx:121
@ RES_POOLCHR_HTML_CODE
Definition: poolfmt.hxx:138
@ RES_POOLCHR_HTML_SAMPLE
Definition: poolfmt.hxx:139
@ RES_POOLCHR_HTML_CITATION
Definition: poolfmt.hxx:136
@ RES_POOLCHR_FOOTNOTE
Footnote.
Definition: poolfmt.hxx:113
@ RES_POOLCHR_HTML_EMPHASIS
Definition: poolfmt.hxx:135
@ RES_POOLCHR_ENDNOTE
Endnote.
Definition: poolfmt.hxx:124
@ RES_POOLCHR_INET_NORMAL
Internet normal.
Definition: poolfmt.hxx:120
@ RES_POOLCHR_HTML_KEYBOARD
Definition: poolfmt.hxx:140
@ RES_POOLCHR_HTML_STRONG
Definition: poolfmt.hxx:137
@ RES_POOLCHR_HTML_DEFINSTANCE
Definition: poolfmt.hxx:142
@ RES_POOLCHR_HTML_VARIABLE
Definition: poolfmt.hxx:141
const sal_uInt16 USER_FMT
POLLCOLL-groups:
Definition: poolfmt.hxx:63
DefTokenId nToken
Marks a position in the document model.
Definition: pam.hxx:38
SwNode & GetNode() const
Definition: pam.hxx:81
sal_Int32 GetContentIndex() const
Definition: pam.hxx:85
@ SVX_CSS1_PBREAK_ALWAYS
Definition: svxcss1.hxx:69
@ SVX_CSS1_PBREAK_AUTO
Definition: svxcss1.hxx:68
@ SVX_CSS1_PBREAK_RIGHT
Definition: svxcss1.hxx:72
@ SVX_CSS1_PBREAK_LEFT
Definition: svxcss1.hxx:71
@ SVX_CSS1_PBREAK_AVOID
Definition: svxcss1.hxx:70
@ SVX_CSS1_STYPE_NONE
Definition: svxcss1.hxx:58
@ SVX_CSS1_STYPE_LANDSCAPE
Definition: svxcss1.hxx:61
@ SVX_CSS1_STYPE_TWIP
Definition: svxcss1.hxx:60
@ SVX_CSS1_STYPE_PORTRAIT
Definition: svxcss1.hxx:62
@ SVX_CSS1_POS_ABSOLUTE
Definition: svxcss1.hxx:43
@ SVX_CSS1_LTYPE_TWIP
Definition: svxcss1.hxx:51
@ SVX_CSS1_LTYPE_PERCENTAGE
Definition: svxcss1.hxx:52
Css1ScriptFlags
Definition: svxcss1.hxx:76
SvxBreak
HtmlFrameFormatFlags
Definition: swhtml.hxx:331
std::deque< HTMLAttr * > HTMLAttrs
Definition: swhtml.hxx:78
tools::Long SwTwips
Definition: swtypes.hxx:51
constexpr SwTwips MIN_BORDER_DIST
Definition: swtypes.hxx:70
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:92
#define MINFLY
Definition: swtypes.hxx:61
unsigned char sal_uInt8
size_t pos