1efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5efeef26fSAndrew Rist * distributed with this work for additional information 6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10efeef26fSAndrew Rist * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12efeef26fSAndrew Rist * 13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14efeef26fSAndrew Rist * software distributed under the License is distributed on an 15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17efeef26fSAndrew Rist * specific language governing permissions and limitations 18efeef26fSAndrew Rist * under the License. 19efeef26fSAndrew Rist * 20efeef26fSAndrew Rist *************************************************************/ 21efeef26fSAndrew Rist 22efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 273078b051SOliver-Rainer Wittmann #include <IDocumentMarkAccess.hxx> 28cdf0e10cSrcweir #include <crossrefbookmark.hxx> 29cdf0e10cSrcweir #include <ndtxt.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir using namespace rtl; 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace sw { namespace mark 34cdf0e10cSrcweir { CrossRefBookmark(const SwPaM & rPaM,const KeyCode & rCode,const OUString & rName,const OUString & rShortName,const OUString & rPrefix)35cdf0e10cSrcweir CrossRefBookmark::CrossRefBookmark(const SwPaM& rPaM, 36cdf0e10cSrcweir const KeyCode& rCode, 37cdf0e10cSrcweir const OUString& rName, 38cdf0e10cSrcweir const OUString& rShortName, 39cdf0e10cSrcweir const OUString& rPrefix) 40cdf0e10cSrcweir : Bookmark(rPaM, rCode, rName, rShortName) 41cdf0e10cSrcweir { 423078b051SOliver-Rainer Wittmann OSL_ENSURE( IDocumentMarkAccess::IsLegalPaMForCrossRefHeadingBookmark( rPaM ), 433078b051SOliver-Rainer Wittmann "<CrossRefBookmark::CrossRefBookmark(..)>" 443078b051SOliver-Rainer Wittmann "- creation of cross-reference bookmark with an illegal PaM that does not expand over exactly one whole paragraph."); 45cdf0e10cSrcweir SetMarkPos(*rPaM.Start()); 46cdf0e10cSrcweir if(!rName.getLength()) 47cdf0e10cSrcweir m_aName = MarkBase::GenerateNewName(rPrefix); 48cdf0e10cSrcweir } 49cdf0e10cSrcweir SetMarkPos(const SwPosition & rNewPos)50cdf0e10cSrcweir void CrossRefBookmark::SetMarkPos(const SwPosition& rNewPos) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir OSL_PRECOND(rNewPos.nNode.GetNode().GetTxtNode(), 53cdf0e10cSrcweir "<SwCrossRefBookmark::SetMarkPos(..)>" 54cdf0e10cSrcweir " - new bookmark position for cross-reference bookmark doesn't mark text node"); 55cdf0e10cSrcweir OSL_PRECOND(rNewPos.nContent.GetIndex() == 0, 56cdf0e10cSrcweir "<SwCrossRefBookmark::SetMarkPos(..)>" 57cdf0e10cSrcweir " - new bookmark position for cross-reference bookmark doesn't mark start of text node"); 58cdf0e10cSrcweir MarkBase::SetMarkPos(rNewPos); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir GetOtherMarkPos() const61*edfeb9b7SOliver-Rainer Wittmann const SwPosition& CrossRefBookmark::GetOtherMarkPos() const 62cdf0e10cSrcweir { 63cdf0e10cSrcweir OSL_PRECOND(false, 64cdf0e10cSrcweir "<SwCrossRefBookmark::GetOtherMarkPos(..)>" 65cdf0e10cSrcweir " - this should never be called!"); 66cdf0e10cSrcweir return *static_cast<SwPosition*>(NULL); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir CrossRefHeadingBookmark(const SwPaM & rPaM,const KeyCode & rCode,const OUString & rName,const OUString & rShortName)69cdf0e10cSrcweir CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM, 70cdf0e10cSrcweir const KeyCode& rCode, 71cdf0e10cSrcweir const OUString& rName, 72cdf0e10cSrcweir const OUString& rShortName) 733078b051SOliver-Rainer Wittmann : CrossRefBookmark(rPaM, rCode, rName, rShortName, IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()) 74cdf0e10cSrcweir { } 75cdf0e10cSrcweir IsLegalName(const::rtl::OUString & rName)76cdf0e10cSrcweir bool CrossRefHeadingBookmark::IsLegalName(const ::rtl::OUString& rName) 77cdf0e10cSrcweir { 783078b051SOliver-Rainer Wittmann return rName.match(IDocumentMarkAccess::GetCrossRefHeadingBookmarkNamePrefix()); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir CrossRefNumItemBookmark(const SwPaM & rPaM,const KeyCode & rCode,const OUString & rName,const OUString & rShortName)81cdf0e10cSrcweir CrossRefNumItemBookmark::CrossRefNumItemBookmark(const SwPaM& rPaM, 82cdf0e10cSrcweir const KeyCode& rCode, 83cdf0e10cSrcweir const OUString& rName, 84cdf0e10cSrcweir const OUString& rShortName) 85cdf0e10cSrcweir : CrossRefBookmark(rPaM, rCode, rName, rShortName, our_sNamePrefix) 86cdf0e10cSrcweir { } 87cdf0e10cSrcweir 88cdf0e10cSrcweir const ::rtl::OUString CrossRefNumItemBookmark::our_sNamePrefix = ::rtl::OUString::createFromAscii("__RefNumPara__"); 89cdf0e10cSrcweir IsLegalName(const::rtl::OUString & rName)90cdf0e10cSrcweir bool CrossRefNumItemBookmark::IsLegalName(const ::rtl::OUString& rName) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir return rName.match(our_sNamePrefix); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir }} 95