Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <crossrefbookmark.hxx>
31 : : #include <ndtxt.hxx>
32 : :
33 : : using ::rtl::OUString;
34 : : namespace sw { namespace mark
35 : : {
36 : 6 : CrossRefBookmark::CrossRefBookmark(const SwPaM& rPaM,
37 : : const KeyCode& rCode,
38 : : const OUString& rName,
39 : : const OUString& rShortName,
40 : : const OUString& rPrefix)
41 [ # # ][ # # ]: 6 : : Bookmark(rPaM, rCode, rName, rShortName)
[ # # ][ + - ]
42 : : {
43 : 6 : if(rPaM.HasMark())
44 : : OSL_ENSURE((rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
45 : : rPaM.Start()->nContent.GetIndex() == 0 &&
46 : : rPaM.End()->nContent.GetIndex() == rPaM.GetPoint()->nNode.GetNode().GetTxtNode()->Len()),
47 : : "<CrossRefBookmark::CrossRefBookmark(..)>"
48 : : "- creation of cross-reference bookmark with an expanded PaM that does not expand over exactly one whole paragraph.");
49 [ # # + - ]: 6 : SetMarkPos(*rPaM.Start());
[ + - ][ # # ]
50 [ # # ][ - + ]: 6 : if(rName.isEmpty())
51 [ # # ][ # # ]: 0 : m_aName = MarkBase::GenerateNewName(rPrefix);
52 : 6 : }
53 : :
54 : 6 : void CrossRefBookmark::SetMarkPos(const SwPosition& rNewPos)
55 : : {
56 : : OSL_PRECOND(rNewPos.nNode.GetNode().GetTxtNode(),
57 : : "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
58 : : " - new bookmark position for cross-reference bookmark doesn't mark text node");
59 : : OSL_PRECOND(rNewPos.nContent.GetIndex() == 0,
60 : : "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
61 : : " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
62 : 6 : MarkBase::SetMarkPos(rNewPos);
63 : 6 : }
64 : :
65 : 0 : SwPosition& CrossRefBookmark::GetOtherMarkPos() const
66 : : {
67 : : OSL_PRECOND(false,
68 : : "<sw::mark::CrossRefBookmark::GetOtherMarkPos(..)>"
69 : : " - this should never be called!");
70 : 0 : return *static_cast<SwPosition*>(NULL);
71 : : }
72 : :
73 : : const char CrossRefHeadingBookmark_NamePrefix[] = "__RefHeading__";
74 : :
75 : 0 : CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM,
76 : : const KeyCode& rCode,
77 : : const OUString& rName,
78 : : const OUString& rShortName)
79 [ # # ][ # # ]: 0 : : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefHeadingBookmark_NamePrefix))
[ # # ][ # # ]
80 : 0 : { }
81 : :
82 : 4006 : bool CrossRefHeadingBookmark::IsLegalName(const ::rtl::OUString& rName)
83 : : {
84 : 4006 : return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefHeadingBookmark_NamePrefix));
85 : : }
86 : :
87 : : const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__";
88 : :
89 : 6 : CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM,
90 : : const KeyCode& rCode,
91 : : const OUString& rName,
92 : : const OUString& rShortName)
93 [ + - ][ + - ]: 6 : : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefNumItemBookmark_NamePrefix))
[ + - ][ # # ]
94 : 6 : { }
95 : :
96 : 4012 : bool CrossRefNumItemBookmark::IsLegalName(const ::rtl::OUString& rName)
97 : : {
98 : 4012 : return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefNumItemBookmark_NamePrefix));
99 : : }
100 : : }}
101 : :
102 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|