1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 /// @HTML 24 25 #ifndef SW_WRITERWORDGLUE 26 #define SW_WRITERWORDGLUE 27 28 # include "needed_cast.hxx" 29 # include "types.hxx" 30 31 class SwFrmFmt; 32 class SfxItemSet; 33 34 namespace sw 35 { 36 namespace types 37 { 38 /** A static_cast style cast for conversion of word types to writer's 39 40 There are a number of places where the winword types are larger 41 than the writer equivalents requiring a cast to silence warnings. 42 To avoid throwing away this useful information writer_cast is used 43 to identify where writer's types are smaller than word's. 44 45 Based on needed_cast it will compile time assert if the cast 46 becomes unnecessary at any time in the future. 47 48 @tplparam 49 Ret the desired return type 50 51 @tplparam 52 Param the type of the in param 53 54 @param 55 in the value to cast from Param to Ret 56 57 @return in casted to type Ret 58 */ writer_cast(Param in)59 template<typename Ret, typename Param> Ret writer_cast(Param in) 60 { 61 return ww::needed_cast<Ret, Param>(in); 62 } 63 64 /** A static_cast style cast for conversion of writer types to word's 65 66 There are a number of places where the writer types are larger than 67 the winword equivalents requiring a cast to silence warnings. To 68 avoid throwing away this useful information writer_cast is used to 69 identify where word's types are smaller than writers's. 70 71 Based on needed_cast it will compile time assert if the cast 72 becomes unnecessary at any time in the future. 73 74 @tplparam 75 Ret the desired return type 76 77 @tplparam 78 Param the type of the in param 79 80 @param 81 in the value to cast from Param to Ret 82 83 @return in casted to type Ret 84 */ msword_cast(Param in)85 template<typename Ret, typename Param> Ret msword_cast(Param in) 86 { 87 return ww::needed_cast<Ret, Param>(in); 88 } 89 } 90 91 namespace util 92 { 93 /** See if two page formats can be expressed as a single word section 94 95 Word doesn't have the idea of page descriptors and follow styles 96 like writer does, the only thing it has is a section with a 97 different title page. The only difference of the title page from 98 the rest of the section is different headers/footers, everything 99 else is the same. 100 101 So this function compares two writer page fmts and sees if the 102 follow frame and the title frame are the same from word persecptive 103 except for the content of their headers. 104 105 @return true if the rTitleFmt followed by rFollowFmt could be 106 expressed in word as a single word Section with different title 107 page enabled. 108 109 @author 110 <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 111 112 @see #i4320#/#i14509#/#i11717# for examples 113 add a param to identify documentype, 0 means NATIVE, 1 means MSWORD 114 */ 115 bool IsPlausableSingleWordSection(const SwFrmFmt &rTitleFmt, 116 const SwFrmFmt &rFollowFmt, sal_Int8 nDocType = 0 ); 117 118 /** Make export a word section top/bottom values easy 119 120 The top and bottom margins in word and writer are expressed in very 121 different ways. This class provides the equivalent word values for 122 header/footer distances from a given writer attrset of a page 123 124 @author 125 <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 126 */ 127 class HdFtDistanceGlue 128 { 129 private: 130 bool mbHasHeader; 131 bool mbHasFooter; 132 public: 133 sal_uInt16 dyaHdrTop; 134 sal_uInt16 dyaHdrBottom; 135 sal_uInt16 dyaTop; 136 sal_uInt16 dyaBottom; 137 HdFtDistanceGlue(const SfxItemSet &rPage); HasHeader() const138 bool HasHeader() const { return mbHasHeader; } HasFooter() const139 bool HasFooter() const { return mbHasFooter; } 140 141 /** Is the top of the page the same in both objects 142 143 Ignoring the difference in header and footers, will the main 144 document text have the same top/bottom bounds in word between 145 both these objects. 146 147 @param 148 rOther the other HdFtDistanceGlue to compare against 149 150 @return true if the main text areas top and bottom is at the 151 same location, false otherwise. 152 */ 153 bool EqualTopBottom(const HdFtDistanceGlue &rOther) const; 154 155 }; 156 } 157 } 158 159 #endif 160 /* vi:set tabstop=4 shiftwidth=4 expandtab: */ 161