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 :
21 : #include <crossrefbookmark.hxx>
22 : #include <ndtxt.hxx>
23 :
24 : using ::rtl::OUString;
25 : namespace sw { namespace mark
26 : {
27 0 : CrossRefBookmark::CrossRefBookmark(const SwPaM& rPaM,
28 : const KeyCode& rCode,
29 : const OUString& rName,
30 : const OUString& rShortName,
31 : const OUString& rPrefix)
32 0 : : Bookmark(rPaM, rCode, rName, rShortName)
33 : {
34 0 : if(rPaM.HasMark())
35 : OSL_ENSURE((rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
36 : rPaM.Start()->nContent.GetIndex() == 0 &&
37 : rPaM.End()->nContent.GetIndex() == rPaM.GetPoint()->nNode.GetNode().GetTxtNode()->Len()),
38 : "<CrossRefBookmark::CrossRefBookmark(..)>"
39 : "- creation of cross-reference bookmark with an expanded PaM that does not expand over exactly one whole paragraph.");
40 0 : SetMarkPos(*rPaM.Start());
41 0 : if(rName.isEmpty())
42 0 : m_aName = MarkBase::GenerateNewName(rPrefix);
43 0 : }
44 :
45 0 : void CrossRefBookmark::SetMarkPos(const SwPosition& rNewPos)
46 : {
47 : OSL_PRECOND(rNewPos.nNode.GetNode().GetTxtNode(),
48 : "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
49 : " - new bookmark position for cross-reference bookmark doesn't mark text node");
50 : OSL_PRECOND(rNewPos.nContent.GetIndex() == 0,
51 : "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
52 : " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
53 0 : MarkBase::SetMarkPos(rNewPos);
54 0 : }
55 :
56 0 : SwPosition& CrossRefBookmark::GetOtherMarkPos() const
57 : {
58 : OSL_PRECOND(false,
59 : "<sw::mark::CrossRefBookmark::GetOtherMarkPos(..)>"
60 : " - this should never be called!");
61 0 : return *static_cast<SwPosition*>(NULL);
62 : }
63 :
64 : const char CrossRefHeadingBookmark_NamePrefix[] = "__RefHeading__";
65 :
66 0 : CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM,
67 : const KeyCode& rCode,
68 : const OUString& rName,
69 : const OUString& rShortName)
70 0 : : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefHeadingBookmark_NamePrefix))
71 0 : { }
72 :
73 15 : bool CrossRefHeadingBookmark::IsLegalName(const ::rtl::OUString& rName)
74 : {
75 15 : return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefHeadingBookmark_NamePrefix));
76 : }
77 :
78 : const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__";
79 :
80 0 : CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM,
81 : const KeyCode& rCode,
82 : const OUString& rName,
83 : const OUString& rShortName)
84 0 : : CrossRefBookmark(rPaM, rCode, rName, rShortName, rtl::OUString(CrossRefNumItemBookmark_NamePrefix))
85 0 : { }
86 :
87 15 : bool CrossRefNumItemBookmark::IsLegalName(const ::rtl::OUString& rName)
88 : {
89 15 : return rName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(CrossRefNumItemBookmark_NamePrefix));
90 : }
91 : }}
92 :
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|