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