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