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 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYMAP_HXX 20 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYMAP_HXX 21 22 #include <rtl/ustring.hxx> 23 #include <com/sun/star/uno/Sequence.hxx> 24 #include <com/sun/star/beans/PropertyValue.hpp> 25 #include <com/sun/star/beans/XPropertySet.hpp> 26 #include <com/sun/star/table/BorderLine2.hpp> 27 #include <com/sun/star/text/WrapTextMode.hpp> 28 #include <com/sun/star/uno/Any.h> 29 #include "PropertyIds.hxx" 30 #include <memory> 31 #include <boost/optional.hpp> 32 #include <map> 33 #include <vector> 34 #include "TagLogger.hxx" 35 36 namespace com { namespace sun { namespace star { 37 namespace beans { 38 struct PropertyValue; 39 } 40 namespace container { 41 class XNameContainer; 42 } 43 namespace lang { 44 class XMultiServiceFactory; 45 } 46 namespace text { 47 class XTextRange; 48 class XTextColumns; 49 class XFootnote; 50 } 51 namespace table { 52 struct BorderLine2; 53 struct ShadowFormat; 54 } 55 }}} 56 57 namespace writerfilter { 58 namespace dmapper { 59 60 class DomainMapper_Impl; 61 struct FloatingTableInfo; 62 struct AnchoredObjectInfo; 63 64 enum BorderPosition 65 { 66 BORDER_LEFT, 67 BORDER_RIGHT, 68 BORDER_TOP, 69 BORDER_BOTTOM 70 }; 71 72 enum GrabBagType 73 { 74 NO_GRAB_BAG, 75 ROW_GRAB_BAG, 76 CELL_GRAB_BAG, 77 PARA_GRAB_BAG, 78 CHAR_GRAB_BAG 79 }; 80 81 struct RedlineParams : public virtual SvRefBase 82 { 83 OUString m_sAuthor; 84 OUString m_sDate; 85 sal_Int32 m_nToken; 86 87 // This can hold properties of runs that had formatted 'track changes' properties 88 css::uno::Sequence< css::beans::PropertyValue > m_aRevertProperties; 89 }; 90 91 typedef tools::SvRef< RedlineParams > RedlineParamsPtr; 92 93 class PropValue 94 { 95 private: 96 css::uno::Any m_aValue; 97 GrabBagType m_GrabBagType; 98 99 public: PropValue(const css::uno::Any & rValue,GrabBagType i_GrabBagType)100 PropValue( const css::uno::Any& rValue, GrabBagType i_GrabBagType ) 101 : m_aValue( rValue ) 102 , m_GrabBagType( i_GrabBagType ) 103 { 104 } 105 PropValue()106 PropValue() 107 : m_aValue() 108 , m_GrabBagType( NO_GRAB_BAG ) 109 { 110 } 111 getValue() const112 const css::uno::Any& getValue() const { return m_aValue; } 113 getGrabBagType() const114 GrabBagType getGrabBagType() const { return m_GrabBagType; } 115 }; 116 117 class PropertyMap; 118 typedef tools::SvRef< PropertyMap > PropertyMapPtr; 119 120 class PropertyMap : public virtual SvRefBase 121 { 122 private: 123 // Cache the property values for the GetPropertyValues() call(s). 124 std::vector< css::beans::PropertyValue > m_aValues; 125 126 // marks context as footnote context - ::text( ) events contain either the footnote character or can be ignored 127 // depending on sprmCSymbol 128 css::uno::Reference< css::text::XFootnote > m_xFootnote; 129 OUString m_sFootnoteCharStyleName; 130 std::map< PropertyIds, PropValue > m_vMap; 131 std::vector< RedlineParamsPtr > m_aRedlines; 132 133 public: 134 typedef std::pair< PropertyIds, css::uno::Any > Property; 135 PropertyMap()136 PropertyMap() {} 137 138 // Sequence: Grab Bags: The CHAR_GRAB_BAG has Name "CharInteropGrabBag" and the PARA_GRAB_BAG has Name "ParaInteropGrabBag" 139 // the contained properties are their Value. 140 css::uno::Sequence< css::beans::PropertyValue > GetPropertyValues( bool bCharGrabBag = true ); 141 142 // Add property, optionally overwriting existing attributes 143 void Insert( PropertyIds eId, const css::uno::Any& rAny, bool bOverwrite = true, GrabBagType i_GrabBagType = NO_GRAB_BAG ); 144 145 // Remove a named property from *this, does nothing if the property id has not been set 146 void Erase( PropertyIds eId); 147 148 // Imports properties from pMap 149 void InsertProps( const PropertyMapPtr& rMap, const bool bOverwrite = true ); 150 151 // Returns a copy of the property if it exists, .first is its PropertyIds and .second is its Value (type css::uno::Any) 152 boost::optional< Property > getProperty( PropertyIds eId ) const; 153 154 // Has the property named been set (via Insert)? 155 bool isSet( PropertyIds eId ) const; 156 GetFootnote() const157 const css::uno::Reference< css::text::XFootnote >& GetFootnote() const { return m_xFootnote; } GetFootnoteStyle() const158 const OUString& GetFootnoteStyle() const { return m_sFootnoteCharStyleName; } 159 SetFootnote(const css::uno::Reference<css::text::XFootnote> & xFootnote,const OUString & sStyleName)160 void SetFootnote(const css::uno::Reference< css::text::XFootnote >& xFootnote, const OUString& sStyleName) 161 { 162 m_xFootnote = xFootnote; 163 m_sFootnoteCharStyleName = sStyleName; 164 } 165 166 virtual void insertTableProperties( const PropertyMap*, const bool bOverwrite = true ); 167 Redlines() const168 const std::vector< RedlineParamsPtr >& Redlines() const { return m_aRedlines; } 169 Redlines()170 std::vector< RedlineParamsPtr >& Redlines() { return m_aRedlines; } 171 172 void printProperties(); 173 174 #ifdef DBG_UTIL 175 void dumpXml() const; 176 #endif 177 178 static css::table::ShadowFormat getShadowFromBorder( const css::table::BorderLine2& rBorder ); 179 180 protected: Invalidate()181 void Invalidate() 182 { 183 if ( m_aValues.size() ) 184 m_aValues.clear(); 185 } 186 }; 187 188 class SectionPropertyMap : public PropertyMap 189 { 190 public: 191 enum class BorderApply 192 { 193 ToAllInSection = 0, 194 ToFirstPageInSection = 1, 195 ToAllButFirstInSection = 2 196 }; 197 enum class BorderOffsetFrom 198 { 199 Text = 0, 200 Edge = 1, 201 }; 202 private: 203 #ifdef DBG_UTIL 204 sal_Int32 m_nDebugSectionNumber; 205 #endif 206 207 // 'temporarily' the section page settings are imported as page styles 208 // empty strings mark page settings as not yet imported 209 210 bool const m_bIsFirstSection; 211 css::uno::Reference< css::text::XTextRange > m_xStartingRange; 212 213 OUString m_sFirstPageStyleName; 214 OUString m_sFollowPageStyleName; 215 css::uno::Reference< css::beans::XPropertySet > m_aFirstPageStyle; 216 css::uno::Reference< css::beans::XPropertySet > m_aFollowPageStyle; 217 218 boost::optional< css::table::BorderLine2 > m_oBorderLines[4]; 219 sal_Int32 m_nBorderDistances[4]; 220 BorderApply m_eBorderApply; 221 BorderOffsetFrom m_eBorderOffsetFrom; 222 bool m_bBorderShadows[4]; 223 224 bool m_bTitlePage; 225 sal_Int16 m_nColumnCount; 226 sal_Int32 m_nColumnDistance; 227 css::uno::Reference< css::beans::XPropertySet > m_xColumnContainer; 228 std::vector< sal_Int32 > m_aColWidth; 229 std::vector< sal_Int32 > m_aColDistance; 230 231 bool m_bSeparatorLineIsOn; 232 bool m_bEvenlySpaced; 233 234 sal_Int32 m_nPageNumber; 235 // Page number type is a value from css::style::NumberingType. 236 sal_Int16 m_nPageNumberType; 237 sal_Int32 m_nBreakType; 238 239 sal_Int32 m_nLeftMargin; 240 sal_Int32 m_nRightMargin; 241 sal_Int32 m_nTopMargin; 242 sal_Int32 m_nBottomMargin; 243 sal_Int32 m_nHeaderTop; 244 sal_Int32 m_nHeaderBottom; 245 246 sal_Int32 m_nGridType; 247 sal_Int32 m_nGridLinePitch; 248 sal_Int32 m_nDxtCharSpace; 249 bool m_bGridSnapToChars; 250 251 // line numbering 252 sal_Int32 m_nLnnMod; 253 sal_uInt32 m_nLnc; 254 sal_Int32 m_ndxaLnn; 255 sal_Int32 m_nLnnMin; 256 257 std::vector<css::uno::Reference<css::drawing::XShape>> m_xRelativeWidthShapes; 258 259 // The "Link To Previous" flag indicates whether the header/footer 260 // content should be taken from the previous section 261 bool m_bDefaultHeaderLinkToPrevious; 262 bool m_bEvenPageHeaderLinkToPrevious; 263 bool m_bFirstPageHeaderLinkToPrevious; 264 bool m_bDefaultFooterLinkToPrevious; 265 bool m_bEvenPageFooterLinkToPrevious; 266 bool m_bFirstPageFooterLinkToPrevious; 267 268 void ApplyProperties_( const css::uno::Reference< css::beans::XPropertySet >& xStyle ); 269 270 void DontBalanceTextColumns(); 271 272 /// Apply section-specific properties: only valid to use after PageStyle has been determined by InheritOrFinalizePageStyles 273 void ApplySectionProperties( const css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); 274 275 /// Check if document is protected. If so, ensure a section exists, and apply its protected value. 276 void ApplyProtectionProperties( css::uno::Reference< css::beans::XPropertySet >& xSection, DomainMapper_Impl& rDM_Impl ); 277 278 css::uno::Reference< css::text::XTextColumns > ApplyColumnProperties( const css::uno::Reference< css::beans::XPropertySet >& xFollowPageStyle, 279 DomainMapper_Impl& rDM_Impl); 280 281 void CopyLastHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl ); 282 283 static void CopyHeaderFooter( const css::uno::Reference< css::beans::XPropertySet >& xPrevStyle, 284 const css::uno::Reference< css::beans::XPropertySet >& xStyle, 285 bool bOmitRightHeader = false, bool bOmitLeftHeader = false, 286 bool bOmitRightFooter = false, bool bOmitLeftFooter = false ); 287 288 static void CopyHeaderFooterTextProperty( const css::uno::Reference< css::beans::XPropertySet >& xPrevStyle, 289 const css::uno::Reference< css::beans::XPropertySet >& xStyle, 290 PropertyIds ePropId ); 291 292 void PrepareHeaderFooterProperties( bool bFirstPage ); 293 294 bool HasHeader( bool bFirstPage ) const; 295 bool HasFooter( bool bFirstPage ) const; 296 297 static void SetBorderDistance( const css::uno::Reference< css::beans::XPropertySet >& xStyle, 298 PropertyIds eMarginId, 299 PropertyIds eDistId, 300 sal_Int32 nDistance, 301 BorderOffsetFrom eOffsetFrom, 302 sal_uInt32 nLineWidth ); 303 304 // Determines if conversion of a given floating table is wanted or not. 305 bool FloatingTableConversion( const DomainMapper_Impl& rDM_Impl, FloatingTableInfo& rInfo ); 306 307 /// Increases paragraph spacing according to Word 2013+ needs if necessary. 308 void HandleIncreasedAnchoredObjectSpacing(DomainMapper_Impl& rDM_Impl); 309 310 public: 311 enum PageType 312 { 313 PAGE_FIRST, 314 PAGE_LEFT, 315 PAGE_RIGHT 316 }; 317 318 explicit SectionPropertyMap( bool bIsFirstSection ); 319 IsFirstSection() const320 bool IsFirstSection() const { return m_bIsFirstSection; } 321 SetStart(const css::uno::Reference<css::text::XTextRange> & xRange)322 void SetStart( const css::uno::Reference< css::text::XTextRange >& xRange ) { m_xStartingRange = xRange; } 323 GetStartingRange() const324 const css::uno::Reference< css::text::XTextRange >& GetStartingRange() const { return m_xStartingRange; } 325 326 css::uno::Reference< css::beans::XPropertySet > GetPageStyle( DomainMapper_Impl& rDM_Impl, bool bFirst ); 327 GetPageStyleName(bool bFirstPage=false)328 const OUString& GetPageStyleName( bool bFirstPage = false ) 329 { 330 return bFirstPage ? m_sFirstPageStyleName : m_sFollowPageStyleName; 331 } 332 333 // @throws css::beans::UnknownPropertyException 334 // @throws css::beans::PropertyVetoException 335 // @throws css::lang::IllegalArgumentException 336 // @throws css::lang::WrappedTargetException 337 // @throws css::uno::RuntimeException 338 void InheritOrFinalizePageStyles( DomainMapper_Impl& rDM_Impl ); 339 340 void SetBorder( BorderPosition ePos, sal_Int32 nLineDistance, const css::table::BorderLine2& rBorderLine, bool bShadow ); SetBorderApply(BorderApply nSet)341 void SetBorderApply( BorderApply nSet ) { m_eBorderApply = nSet; } SetBorderOffsetFrom(BorderOffsetFrom nSet)342 void SetBorderOffsetFrom( BorderOffsetFrom nSet ) { m_eBorderOffsetFrom = nSet; } 343 SetColumnCount(sal_Int16 nCount)344 void SetColumnCount( sal_Int16 nCount ) { m_nColumnCount = nCount; } ColumnCount() const345 sal_Int16 ColumnCount() const { return m_nColumnCount; } 346 SetColumnDistance(sal_Int32 nDist)347 void SetColumnDistance( sal_Int32 nDist ) { m_nColumnDistance = nDist; } AppendColumnWidth(sal_Int32 nWidth)348 void AppendColumnWidth( sal_Int32 nWidth ) { m_aColWidth.push_back( nWidth ); } AppendColumnSpacing(sal_Int32 nDist)349 void AppendColumnSpacing( sal_Int32 nDist ) { m_aColDistance.push_back( nDist ); } 350 SetTitlePage(bool bSet)351 void SetTitlePage( bool bSet ) { m_bTitlePage = bSet; } SetSeparatorLine(bool bSet)352 void SetSeparatorLine( bool bSet ) { m_bSeparatorLineIsOn = bSet; } SetEvenlySpaced(bool bSet)353 void SetEvenlySpaced( bool bSet ) { m_bEvenlySpaced = bSet; } SetPageNumber(sal_Int32 nSet)354 void SetPageNumber( sal_Int32 nSet ) { m_nPageNumber = nSet; } SetPageNumberType(sal_Int32 nSet)355 void SetPageNumberType( sal_Int32 nSet ) { m_nPageNumberType = nSet; } SetBreakType(sal_Int32 nSet)356 void SetBreakType( sal_Int32 nSet ) { m_nBreakType = nSet; } 357 // GetBreakType returns -1 if the breakType has not yet been identified for the section GetBreakType() const358 sal_Int32 GetBreakType() const { return m_nBreakType; } 359 SetLeftMargin(sal_Int32 nSet)360 void SetLeftMargin( sal_Int32 nSet ) { m_nLeftMargin = nSet; } GetLeftMargin() const361 sal_Int32 GetLeftMargin() const { return m_nLeftMargin; } SetRightMargin(sal_Int32 nSet)362 void SetRightMargin( sal_Int32 nSet ) { m_nRightMargin = nSet; } GetRightMargin() const363 sal_Int32 GetRightMargin() const { return m_nRightMargin; } SetTopMargin(sal_Int32 nSet)364 void SetTopMargin( sal_Int32 nSet ) { m_nTopMargin = nSet; } SetBottomMargin(sal_Int32 nSet)365 void SetBottomMargin( sal_Int32 nSet ) { m_nBottomMargin = nSet; } SetHeaderTop(sal_Int32 nSet)366 void SetHeaderTop( sal_Int32 nSet ) { m_nHeaderTop = nSet; } SetHeaderBottom(sal_Int32 nSet)367 void SetHeaderBottom( sal_Int32 nSet ) { m_nHeaderBottom = nSet; } 368 sal_Int32 GetPageWidth() const; 369 SetGridType(sal_Int32 nSet)370 void SetGridType( sal_Int32 nSet ) { m_nGridType = nSet; } SetGridLinePitch(sal_Int32 nSet)371 void SetGridLinePitch( sal_Int32 nSet ) { m_nGridLinePitch = nSet; } SetGridSnapToChars(bool bSet)372 void SetGridSnapToChars( bool bSet ) { m_bGridSnapToChars = bSet; } SetDxtCharSpace(sal_Int32 nSet)373 void SetDxtCharSpace( sal_Int32 nSet ) { m_nDxtCharSpace = nSet; } 374 SetLnnMod(sal_Int32 nValue)375 void SetLnnMod( sal_Int32 nValue ) { m_nLnnMod = nValue; } SetLnc(sal_Int32 nValue)376 void SetLnc( sal_Int32 nValue ) { m_nLnc = nValue; } SetdxaLnn(sal_Int32 nValue)377 void SetdxaLnn( sal_Int32 nValue ) { m_ndxaLnn = nValue; } SetLnnMin(sal_Int32 nValue)378 void SetLnnMin( sal_Int32 nValue ) { m_nLnnMin = nValue; } 379 addRelativeWidthShape(css::uno::Reference<css::drawing::XShape> xShape)380 void addRelativeWidthShape( css::uno::Reference<css::drawing::XShape> xShape ) { m_xRelativeWidthShapes.push_back( xShape ); } 381 382 // determine which style gets the borders 383 void ApplyBorderToPageStyles( DomainMapper_Impl &rDM_Impl, 384 BorderApply eBorderApply, BorderOffsetFrom eOffsetFrom ); 385 386 void CloseSectionGroup( DomainMapper_Impl& rDM_Impl ); 387 // Handling of margins, header and footer for any kind of sections breaks. 388 void HandleMarginsHeaderFooter( bool bFirstPage, DomainMapper_Impl& rDM_Impl ); 389 void ClearHeaderFooterLinkToPrevious( bool bHeader, PageType eType ); 390 }; 391 392 class ParagraphProperties : public virtual SvRefBase 393 { 394 private: 395 bool m_bFrameMode; 396 sal_Int32 m_nDropCap; // drop, margin ST_DropCap 397 sal_Int32 m_nLines; // number of lines of the drop cap 398 sal_Int32 m_w; // width 399 sal_Int32 m_h; // height 400 css::text::WrapTextMode m_nWrap; // from ST_Wrap around, auto, none, notBeside, through, tight 401 sal_Int32 m_hAnchor; // page, from ST_HAnchor margin, page, text 402 sal_Int32 m_vAnchor; // around from ST_VAnchor margin, page, text 403 sal_Int32 m_x; // x-position 404 bool m_bxValid; 405 sal_Int32 m_y; // y-position 406 bool m_byValid; 407 sal_Int32 m_hSpace; // frame padding h 408 sal_Int32 m_vSpace; // frame padding v 409 sal_Int32 m_hRule; // from ST_HeightRule exact, atLeast, auto 410 sal_Int32 m_xAlign; // from ST_XAlign center, inside, left, outside, right 411 sal_Int32 m_yAlign; // from ST_YAlign bottom, center, inline, inside, outside, top 412 sal_Int8 m_nDropCapLength; // number of characters 413 OUString m_sParaStyleName; 414 415 css::uno::Reference< css::text::XTextRange > m_xStartingRange; // start of a frame 416 css::uno::Reference< css::text::XTextRange > m_xEndingRange; // end of the frame 417 sal_Int32 m_nListId = -1; 418 419 public: 420 ParagraphProperties(); 421 422 ParagraphProperties(ParagraphProperties const &) = default; 423 ParagraphProperties(ParagraphProperties &&) = default; 424 ParagraphProperties & operator =(ParagraphProperties const &) = default; 425 ParagraphProperties & operator =(ParagraphProperties &&) = default; 426 427 // Does not compare the starting/ending range, m_sParaStyleName and m_nDropCapLength 428 bool operator==( const ParagraphProperties& ); 429 GetListId() const430 sal_Int32 GetListId() const { return m_nListId; } SetListId(sal_Int32 nId)431 void SetListId( sal_Int32 nId ) { m_nListId = nId; } 432 IsFrameMode() const433 bool IsFrameMode() const { return m_bFrameMode; } SetFrameMode(bool set=true)434 void SetFrameMode( bool set = true ) { m_bFrameMode = set; } 435 GetDropCap() const436 sal_Int32 GetDropCap() const { return m_nDropCap; } SetDropCap(sal_Int32 nSet)437 void SetDropCap( sal_Int32 nSet ) { m_nDropCap = nSet; } 438 GetLines() const439 sal_Int32 GetLines() const { return m_nLines; } SetLines(sal_Int32 nSet)440 void SetLines( sal_Int32 nSet ) { m_nLines = nSet; } 441 Getw() const442 sal_Int32 Getw() const { return m_w; } Setw(sal_Int32 nSet)443 void Setw( sal_Int32 nSet ) { m_w = nSet; } 444 Geth() const445 sal_Int32 Geth() const { return m_h; } Seth(sal_Int32 nSet)446 void Seth( sal_Int32 nSet ) { m_h = nSet; } 447 GetWrap() const448 css::text::WrapTextMode GetWrap() const { return m_nWrap; } SetWrap(css::text::WrapTextMode nSet)449 void SetWrap( css::text::WrapTextMode nSet ) { m_nWrap = nSet; } 450 GethAnchor() const451 sal_Int32 GethAnchor() const { return m_hAnchor; } SethAnchor(sal_Int32 nSet)452 void SethAnchor( sal_Int32 nSet ) { m_hAnchor = nSet; } 453 GetvAnchor() const454 sal_Int32 GetvAnchor() const { return m_vAnchor; } SetvAnchor(sal_Int32 nSet)455 void SetvAnchor( sal_Int32 nSet ) { m_vAnchor = nSet; } 456 Getx() const457 sal_Int32 Getx() const { return m_x; } Setx(sal_Int32 nSet)458 void Setx( sal_Int32 nSet ) { m_x = nSet; m_bxValid = true; } IsxValid() const459 bool IsxValid() const { return m_bxValid; } 460 Gety() const461 sal_Int32 Gety() const { return m_y; } Sety(sal_Int32 nSet)462 void Sety( sal_Int32 nSet ) { m_y = nSet; m_byValid = true; } IsyValid() const463 bool IsyValid() const { return m_byValid; } 464 SethSpace(sal_Int32 nSet)465 void SethSpace( sal_Int32 nSet ) { m_hSpace = nSet; } GethSpace() const466 sal_Int32 GethSpace() const { return m_hSpace; } 467 GetvSpace() const468 sal_Int32 GetvSpace() const { return m_vSpace; } SetvSpace(sal_Int32 nSet)469 void SetvSpace( sal_Int32 nSet ) { m_vSpace = nSet; } 470 GethRule() const471 sal_Int32 GethRule() const { return m_hRule; } SethRule(sal_Int32 nSet)472 void SethRule( sal_Int32 nSet ) { m_hRule = nSet; } 473 GetxAlign() const474 sal_Int32 GetxAlign() const { return m_xAlign; } SetxAlign(sal_Int32 nSet)475 void SetxAlign( sal_Int32 nSet ) { m_xAlign = nSet; } 476 GetyAlign() const477 sal_Int32 GetyAlign() const { return m_yAlign; } SetyAlign(sal_Int32 nSet)478 void SetyAlign( sal_Int32 nSet ) { m_yAlign = nSet; } 479 GetDropCapLength() const480 sal_Int8 GetDropCapLength() const { return m_nDropCapLength; } SetDropCapLength(sal_Int8 nSet)481 void SetDropCapLength( sal_Int8 nSet ) { m_nDropCapLength = nSet; } 482 GetStartingRange() const483 const css::uno::Reference< css::text::XTextRange >& GetStartingRange() const { return m_xStartingRange; } SetStartingRange(const css::uno::Reference<css::text::XTextRange> & xSet)484 void SetStartingRange( const css::uno::Reference< css::text::XTextRange >& xSet ) { m_xStartingRange = xSet; } 485 GetEndingRange() const486 const css::uno::Reference< css::text::XTextRange >& GetEndingRange() const { return m_xEndingRange; } SetEndingRange(const css::uno::Reference<css::text::XTextRange> & xSet)487 void SetEndingRange( const css::uno::Reference< css::text::XTextRange >& xSet ) { m_xEndingRange = xSet; } 488 GetParaStyleName() const489 const OUString& GetParaStyleName() const { return m_sParaStyleName; } SetParaStyleName(const OUString & rSet)490 void SetParaStyleName( const OUString& rSet ) { m_sParaStyleName = rSet; } 491 492 void ResetFrameProperties(); 493 }; 494 495 typedef tools::SvRef< ParagraphProperties > ParagraphPropertiesPtr; 496 497 /*------------------------------------------------------------------------- 498 property map of a stylesheet 499 -----------------------------------------------------------------------*/ 500 501 #define WW_OUTLINE_MAX sal_Int16( 9 ) 502 #define WW_OUTLINE_MIN sal_Int16( 0 ) 503 504 class StyleSheetPropertyMap 505 : public PropertyMap 506 , public ParagraphProperties 507 { 508 private: 509 sal_Int16 mnListLevel; 510 sal_Int16 mnOutlineLevel; 511 sal_Int32 mnNumId; 512 513 public: 514 explicit StyleSheetPropertyMap(); 515 GetListLevel() const516 sal_Int16 GetListLevel() const { return mnListLevel; } SetListLevel(sal_Int16 nLevel)517 void SetListLevel( sal_Int16 nLevel ) { mnListLevel = nLevel; } 518 GetOutlineLevel() const519 sal_Int16 GetOutlineLevel() const { return mnOutlineLevel; } SetOutlineLevel(sal_Int16 nLevel)520 void SetOutlineLevel( sal_Int16 nLevel ) { if ( nLevel < WW_OUTLINE_MAX ) mnOutlineLevel = nLevel; } 521 GetNumId() const522 sal_Int32 GetNumId() const { return mnNumId; } SetNumId(sal_Int32 nId)523 void SetNumId(sal_Int32 nId) { mnNumId = nId; } 524 }; 525 526 class ParagraphPropertyMap 527 : public PropertyMap 528 , public ParagraphProperties 529 { 530 public: ParagraphPropertyMap()531 explicit ParagraphPropertyMap() {} 532 }; 533 534 class TablePropertyMap 535 : public PropertyMap 536 { 537 public: 538 enum TablePropertyMapTarget 539 { 540 TablePropertyMapTarget_START, 541 CELL_MAR_LEFT = TablePropertyMapTarget_START, 542 CELL_MAR_RIGHT, 543 CELL_MAR_TOP, 544 CELL_MAR_BOTTOM, 545 TABLE_WIDTH, 546 TABLE_WIDTH_TYPE, 547 GAP_HALF, 548 LEFT_MARGIN, 549 HORI_ORIENT, 550 TablePropertyMapTarget_MAX 551 }; 552 553 private: 554 struct ValidValue 555 { 556 sal_Int32 nValue; 557 bool bValid; 558 ValidValuewriterfilter::dmapper::TablePropertyMap::ValidValue559 ValidValue() 560 : nValue( 0 ) 561 , bValid( false ) 562 { 563 } 564 }; 565 566 ValidValue m_aValidValues[TablePropertyMapTarget_MAX]; 567 568 public: TablePropertyMap()569 explicit TablePropertyMap() {} 570 571 bool getValue( TablePropertyMapTarget eWhich, sal_Int32& nFill ); 572 void setValue( TablePropertyMapTarget eWhich, sal_Int32 nSet ); 573 574 virtual void insertTableProperties( const PropertyMap*, const bool bOverwrite = true ) override; 575 }; 576 577 typedef tools::SvRef< TablePropertyMap > TablePropertyMapPtr; 578 579 /// Information about a paragraph to be finished after a table end. 580 struct TableParagraph 581 { 582 PropertyMapPtr m_pPropertyMap; 583 css::uno::Reference<css::beans::XPropertySet> m_rPropertySet; 584 }; 585 586 typedef std::shared_ptr< std::vector<TableParagraph> > TableParagraphVectorPtr; 587 588 } // namespace dmapper 589 } // namespace writerfilter 590 591 #endif // INCLUDED_WRITERFILTER_SOURCE_DMAPPER_PROPERTYMAP_HXX 592 593 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 594