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