LibreOffice Module sw (master)  1
crossrefbookmark.cxx
Go to the documentation of this file.
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 <sal/config.h>
21 
22 #include <cstdlib>
23 
24 #include <IDocumentMarkAccess.hxx>
25 #include <crossrefbookmark.hxx>
26 #include <ndtxt.hxx>
27 
28 namespace
29 {
30  const char CrossRefNumItemBookmark_NamePrefix[] = "__RefNumPara__";
31 }
32 
33 namespace sw { namespace mark
34 {
36  const vcl::KeyCode& rCode,
37  const OUString& rName,
38  const OUString& rPrefix)
39  : Bookmark(
40  // ensure that m_pPos2 is null by only passing start to super
41  SwPaM(*rPaM.Start()), rCode, rName)
42  {
44  && "<CrossRefBookmark::CrossRefBookmark(..)>"
45  "- creation of cross-reference bookmark with an illegal PaM that does not expand over exactly one whole paragraph.");
46  if(rName.isEmpty())
48  assert(!m_pPos2);
49  }
50 
52  {
53  assert(rNewPos.nNode.GetNode().GetTextNode() &&
54  "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
55  " - new bookmark position for cross-reference bookmark doesn't mark text node");
56  assert(rNewPos.nContent.GetIndex() == 0 &&
57  "<sw::mark::CrossRefBookmark::SetMarkPos(..)>"
58  " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
59  MarkBase::SetMarkPos(rNewPos);
60  }
61 
63  {
64  assert(false &&
65  "<sw::mark::CrossRefBookmark::GetOtherMarkPos(..)>"
66  " - this should never be called!");
67  for (;;) { std::abort(); } // avoid "must return a value" warnings
68  }
69 
71  const vcl::KeyCode& rCode,
72  const OUString& rName)
73  : CrossRefBookmark(rPaM, rCode, rName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()+"_Toc")
74  { }
75 
76  bool CrossRefHeadingBookmark::IsLegalName(const OUString& rName)
77  {
79  }
80 
82  const vcl::KeyCode& rCode,
83  const OUString& rName)
84  : CrossRefBookmark(rPaM, rCode, rName, CrossRefNumItemBookmark_NamePrefix)
85  { }
86 
87  bool CrossRefNumItemBookmark::IsLegalName(const OUString& rName)
88  {
89  return rName.match(CrossRefNumItemBookmark_NamePrefix);
90  }
91 }}
92 
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_aName
Definition: bookmrk.hxx:120
static OUString GenerateNewName(const OUString &rPrefix)
Definition: bookmrk.cxx:213
Marks a position in the document model.
Definition: pam.hxx:35
virtual SwPosition & GetOtherMarkPos() const override
CrossRefHeadingBookmark(const SwPaM &rPaM, const vcl::KeyCode &rCode, const OUString &rName)
SwNodeIndex nNode
Definition: pam.hxx:37
Provides access to the marks of a document.
CrossRefNumItemBookmark(const SwPaM &rPaM, const vcl::KeyCode &rCode, const OUString &rName)
SwNode & GetNode() const
Definition: ndindex.hxx:118
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:38
static bool IsLegalName(const OUString &rName)
static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix()
Definition: docbm.cxx:517
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:522
SwIndex nContent
Definition: pam.hxx:38
std::unique_ptr< SwPosition > m_pPos2
Definition: bookmrk.hxx:119
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
CrossRefBookmark(const SwPaM &rPaM, const vcl::KeyCode &rCode, const OUString &rName, const OUString &rPrefix)
sal_Int32 GetIndex() const
Definition: index.hxx:95
virtual void SetMarkPos(const SwPosition &rNewPos)
Definition: bookmrk.cxx:175
static bool IsLegalName(const OUString &rName)
virtual void SetMarkPos(const SwPosition &rNewPos) override
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843