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