1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: crossrefbookmark.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include <crossrefbookmark.hxx>
39 namespace sw
{ namespace mark
41 CrossRefBookmark::CrossRefBookmark(const SwPaM
& rPaM
,
43 const OUString
& rName
,
44 const OUString
& rShortName
,
45 const OUString
& rPrefix
)
46 : Bookmark(rPaM
, rCode
, rName
, rShortName
)
49 OSL_ENSURE((rPaM
.GetMark()->nNode
== rPaM
.GetPoint()->nNode
&&
50 rPaM
.Start()->nContent
.GetIndex() == 0 &&
51 rPaM
.End()->nContent
.GetIndex() == rPaM
.GetPoint()->nNode
.GetNode().GetTxtNode()->Len()),
52 "<CrossRefBookmark::CrossRefBookmark(..)>"
53 "- creation of cross-reference bookmark with an expanded PaM that does not expand over exactly one whole paragraph.");
54 SetMarkPos(*rPaM
.Start());
55 if(!rName
.getLength())
56 m_aName
= MarkBase::GenerateNewName(rPrefix
);
59 void CrossRefBookmark::SetMarkPos(const SwPosition
& rNewPos
)
61 OSL_PRECOND(rNewPos
.nNode
.GetNode().GetTxtNode(),
62 "<SwCrossRefBookmark::SetMarkPos(..)>"
63 " - new bookmark position for cross-reference bookmark doesn't mark text node");
64 OSL_PRECOND(rNewPos
.nContent
.GetIndex() == 0,
65 "<SwCrossRefBookmark::SetMarkPos(..)>"
66 " - new bookmark position for cross-reference bookmark doesn't mark start of text node");
67 MarkBase::SetMarkPos(rNewPos
);
70 SwPosition
& CrossRefBookmark::GetOtherMarkPos() const
73 "<SwCrossRefBookmark::GetOtherMarkPos(..)>"
74 " - this should never be called!");
75 return *static_cast<SwPosition
*>(NULL
);
78 CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM
& rPaM
,
80 const OUString
& rName
,
81 const OUString
& rShortName
)
82 : CrossRefBookmark(rPaM
, rCode
, rName
, rShortName
, our_sNamePrefix
)
85 const ::rtl::OUString
CrossRefHeadingBookmark::our_sNamePrefix
= ::rtl::OUString::createFromAscii("__RefHeading__");
87 bool CrossRefHeadingBookmark::IsLegalName(const ::rtl::OUString
& rName
)
89 return rName
.match(our_sNamePrefix
);
92 CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM
& rPaM
,
94 const OUString
& rName
,
95 const OUString
& rShortName
)
96 : CrossRefBookmark(rPaM
, rCode
, rName
, rShortName
, our_sNamePrefix
)
99 const ::rtl::OUString
CrossRefNumItemBookmark::our_sNamePrefix
= ::rtl::OUString::createFromAscii("__RefNumPara__");
101 bool CrossRefNumItemBookmark::IsLegalName(const ::rtl::OUString
& rName
)
103 return rName
.match(our_sNamePrefix
);