libraries/tbs/plugins/tbs_plugin_opentbs.php
function OpenDoc_GetPage($Tag, $Txt, $Pos, $Forward, $LevelStop) {

		$this->OpenDoc_StylesInit();

		$p = $Pos;

		while (	($loc = clsTbsXmlLoc::FindStartTagHavingAtt($Txt, 'text:style-name', $p, $Forward))!==false) {

			$style = $loc->GetAttLazy('text:style-name');

			if ( ($style!==false) && isset($this->OpenDoc_Styles[$style]) ) {
				$pbreak = $this->OpenDoc_Styles[$style]->pbreak;
				if ($pbreak!==false) {
					if ($Forward) {
						// Forward
						if ($pbreak==='before') {
							return $loc->PosBeg -1; // note that the page-break is not in the block
						} else {
							$loc->FindEndTag();
							return $loc->PosEnd;
						}
					} else {
						// Backward
						if ($pbreak==='before') {
							return $loc->PosBeg;
						} else {
							$loc->FindEndTag();
							return $loc->PosEnd+1; // note that the page-break is not in the block
						}
					}
				}
			}

			$p = ($Forward) ? $loc->PosEnd : $loc->PosBeg; 

		}

		// If we are here, then no tag is found, we return the boud of the main element
		if ($Forward) {
			$p = strpos($Txt, '</office:text');
			if ($p===false) return false;
			return $p-1;
		} else {
			$loc = clsTbsXmlLoc::FindStartTag($Txt, 'office:text', $Pos, false);
			if ($loc===false) return false;
			return $loc->PosEnd + 1;
		}

	}
function OpenDoc_GetPage($Tag, $Txt, $Pos, $Forward, $LevelStop) {

		$this->OpenDoc_StylesInit();

		$p = $Pos;

		while (	($loc = clsTbsXmlLoc::FindStartTagHavingAtt($Txt, 'text:style-name', $p, $Forward))!==false) {

			$style = $loc->GetAttLazy('text:style-name');

			if ( ($style!==false) && isset($this->OpenDoc_Styles[$style]) ) {
				$pbreak = $this->OpenDoc_Styles[$style]->pbreak;
				if ($pbreak!==false) {
					if ($Forward) {
						// Forward
						if ($pbreak==='before') {
							return $loc->PosBeg -1; // note that the page-break is not in the block
						} else {
							$loc->FindEndTag();
							return $loc->PosEnd;
						}
					} else {
						// Backward
						if ($pbreak==='before') {
							return $loc->PosBeg;
						} else {
							$loc->FindEndTag();
							return $loc->PosEnd+1; // note that the page-break is not in the block
						}
					}
				}
			}

			$p = ($Forward) ? $loc->PosEnd : $loc->PosBeg; 

		}

		// If we are here, then no tag is found, we return the boud of the main element
		if ($Forward) {
			$p = strpos($Txt, '</office:text');
			if ($p===false) return false;
			return $p-1;
		} else {
			$loc = clsTbsXmlLoc::FindStartTag($Txt, 'office:text', $Pos, false);
			if ($loc===false) return false;
			return $loc->PosEnd + 1;
		}

	}
function OpenDoc_GetPage ( $ Tag , $ Txt , $ Pos , $ Forward , $ LevelStop ) { $ this -> OpenDoc_StylesInit ( ) ; $ p = $ Pos ; while ( ( $ loc = clsTbsXmlLoc :: FindStartTagHavingAtt ( $ Txt , 'text:style-name' , $ p , $ Forward ) ) !== false ) { $ style = $ loc -> GetAttLazy ( 'text:style-name' ) ; if ( ( $ style !== false ) && isset ( $ this -> OpenDoc_Styles [ $ style ] ) ) { $ pbreak = $ this -> OpenDoc_Styles [ $ style ] -> pbreak ; if ( $ pbreak !== false ) { if ( $ Forward ) { // Forward if ( $ pbreak === 'before' ) { return $ loc -> PosBeg - 1 ; // note that the page-break is not in the block } else { $ loc -> FindEndTag ( ) ; return $ loc -> PosEnd ; } } else { // Backward if ( $ pbreak === 'before' ) { return $ loc -> PosBeg ; } else { $ loc -> FindEndTag ( ) ; return $ loc -> PosEnd + 1 ; // note that the page-break is not in the block } } } } $ p = ( $ Forward ) ? $ loc -> PosEnd : $ loc -> PosBeg ; } // If we are here, then no tag is found, we return the boud of the main element if ( $ Forward ) { $ p = strpos ( $ Txt , '</office:text' ) ; if ( $ p === false ) return false ; return $ p - 1 ; } else { $ loc = clsTbsXmlLoc :: FindStartTag ( $ Txt , 'office:text' , $ Pos , false ) ; if ( $ loc === false ) return false ; return $ loc -> PosEnd + 1 ; } }
TBS Block Alias for pages
TBS Block Alias for pages