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