LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - writerwordglue.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 6 6 100.0 %
Date: 2014-04-11 Functions: 9 12 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #ifndef SW_WRITERWORDGLUE
      21             : #define SW_WRITERWORDGLUE
      22             : 
      23             : #include "needed_cast.hxx"
      24             : #include "types.hxx"
      25             : 
      26             : class SwFrmFmt;
      27             : class SfxItemSet;
      28             : 
      29             : namespace sw
      30             : {
      31             :     namespace types
      32             :     {
      33             :         /** A static_cast style cast for conversion of word types to writer's
      34             : 
      35             :             There are a number of places where the winword types are larger
      36             :             than the writer equivalents requiring a cast to silence warnings.
      37             :             To avoid throwing away this useful information writer_cast is used
      38             :             to identify where writer's types are smaller than word's.
      39             : 
      40             :             Based on needed_cast it will compile time assert if the cast
      41             :             becomes unnecessary at any time in the future.
      42             : 
      43             :             @tplparam
      44             :             Ret the desired return type
      45             : 
      46             :             @tplparam
      47             :             Param the type of the in param
      48             : 
      49             :             @param
      50             :             in the value to cast from Param to Ret
      51             : 
      52             :             @return in casted to type Ret
      53             :         */
      54         728 :         template<typename Ret, typename Param> Ret writer_cast(Param in)
      55             :         {
      56         728 :             return ww::needed_cast<Ret, Param>(in);
      57             :         }
      58             : 
      59             :         /** A static_cast style cast for conversion of writer types to word's
      60             : 
      61             :             There are a number of places where the writer types are larger than
      62             :             the winword equivalents requiring a cast to silence warnings.  To
      63             :             avoid throwing away this useful information writer_cast is used to
      64             :             identify where word's types are smaller than writers's.
      65             : 
      66             :             Based on needed_cast it will compile time assert if the cast
      67             :             becomes unnecessary at any time in the future.
      68             : 
      69             :             @tplparam
      70             :             Ret the desired return type
      71             : 
      72             :             @tplparam
      73             :             Param the type of the in param
      74             : 
      75             :             @param
      76             :             in the value to cast from Param to Ret
      77             : 
      78             :             @return in casted to type Ret
      79             :         */
      80         146 :         template<typename Ret, typename Param> Ret msword_cast(Param in)
      81             :         {
      82         146 :             return ww::needed_cast<Ret, Param>(in);
      83             :         }
      84             :     }
      85             : 
      86             :     namespace util
      87             :     {
      88             :         /** See if two page formats can be expressed as a single word section
      89             : 
      90             :             Word doesn't have the idea of page descriptors and follow styles
      91             :             like writer does, the only thing it has is a section with a
      92             :             different title page. The only difference of the title page from
      93             :             the rest of the section is different headers/footers, everything
      94             :             else is the same.
      95             : 
      96             :             So this function compares two writer page fmts and sees if the
      97             :             follow frame and the title frame are the same from word persecptive
      98             :             except for the content of their headers.
      99             : 
     100             :             @return true if the rTitleFmt followed by rFollowFmt could be
     101             :             expressed in word as a single word Section with different title
     102             :             page enabled.
     103             : 
     104             :             @author
     105             :             <a href="mailto:cmc@openoffice.org">Caol&aacute;n McNamara</a>
     106             : 
     107             :             @see #i4320#/#i14509#/#i11717# for examples
     108             :         */
     109             :         bool IsPlausableSingleWordSection(const SwFrmFmt &rTitleFmt,
     110             :             const SwFrmFmt &rFollowFmt);
     111             : 
     112             :         /** Make export a word section top/bottom values easy
     113             : 
     114             :             The top and bottom margins in word and writer are expressed in very
     115             :             different ways. This class provides the equivalent word values for
     116             :             header/footer distances from a given writer attrset of a page
     117             : 
     118             :             @author
     119             :             <a href="mailto:cmc@openoffice.org">Caol&aacute;n McNamara</a>
     120             :         */
     121             :         class HdFtDistanceGlue
     122             :         {
     123             :         private:
     124             :             bool mbHasHeader;
     125             :             bool mbHasFooter;
     126             :         public:
     127             :             sal_uInt16 dyaHdrTop;
     128             :             sal_uInt16 dyaHdrBottom;
     129             :             sal_uInt16 dyaTop;
     130             :             sal_uInt16 dyaBottom;
     131             :             HdFtDistanceGlue(const SfxItemSet &rPage);
     132         516 :             bool HasHeader() const { return mbHasHeader; }
     133         517 :             bool HasFooter() const { return mbHasFooter; }
     134             : 
     135             :             /** Is the top of the page the same in both objects
     136             :                 when there are headers\footers present or non-present in both objects
     137             : 
     138             :                 This test is important, because we would like to ignore cases
     139             :                 when there is a header in one object and no header in the second
     140             :                 object - because it is wrong to compare between them.
     141             : 
     142             :                 @param
     143             :                 rOther the other HdFtDistanceGlue to compare against
     144             : 
     145             :                 @return true if the main text areas top and bottom is at the
     146             :                 same location, false otherwise (assuming both objects have\don't have
     147             :                 a header\footer)
     148             :             */
     149             :             bool StrictEqualTopBottom(const HdFtDistanceGlue &rOther) const;
     150             : 
     151             :         };
     152             :     }
     153             : }
     154             : 
     155             : #endif
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10